2016-11-25 2 views
0

Zoho에서 새 인보이스를 만들기 위해 Zapier 앱을 만들려고합니다. 콘텐츠 형식 : 응용 프로그램 : Zapier 앱에서 json을 쿼리 매개 변수로 포함하는 방법

는 요구 사항이 x-www-form-urlencoded를 입력 JSON 문자열 JSONString 매개 변수를 사용하여 전달해야

나는 내용을 설정할 때 다음 URI가 REST 콘솔에서 나를 위해 노력하고 있습니다 "application/x-www-form-urlencoded"를 입력하고 POST를 입력하십시오.

https://invoice.zoho.com/api/v3/invoices?authtoken=xxxxxx&organization_id=xxxxxx&JSONString={"customer_id":"xxxxxx","line_items":[{"item_id":"xxxxxx"}]} 

그러나 제 문제는 이것을 Zapier에 구현하려고합니다. 아래의 함수를 사용하여 JSON을 올바른 형식으로 변환해야한다고 생각하지만 JSONString이라는 쿼리 매개 변수로 변환하는 방법을 알지 못합니다.

create_invoice_pre_write: function(bundle) { 
    var data = JSON.parse(bundle.request.data); 
    bundle.request.data = $.param(data); 
    bundle.request.headers['Content-Type'] = 'application/x-www-form-urlencoded'; 
    return bundle.request; 
} 

올바른 방향으로 포인트가 필요합니다. 다음에 무엇을 시도해야할지 모르겠습니다.

답변

1

아래 코드를 사용하여 Zoho Invoice에서 청구서를 작성할 수 있습니다.

송장 작성을 위해 ZI로 보내려는 bundle.request.params에서 쿼리 매개 변수를 설정할 수 있습니다.

create_invoice_pre_write: function(bundle) 
{ 
var data = JSON.parse(bundle.request.data); 
bundle.request.method = "POST", 
bundle.request.url = "https://invoice.zoho.com/api/v3/invoices", 
bundle.request.params.authtoken = {authtoken}, 
bundle.request.params.organization_id = {organization_id}, 
bundle.request.params.JSONString = data 
bundle.request.headers= "'Content-Type':'application/x-www-form-urlencoded'"; 
    return bundle.request; 
} 

이 방법이 효과적입니다. 혹시 의심이 있으시면 알려주세요.