2016-08-02 2 views
2

누구나 Google Apps Script를 사용하여 QuickBooks API에 대한 POST를 수행하는 실제 사례가 있습니까?Google Apps 스크립트를 사용하는 QuickBooks API POST

내가 요청 본문 아래 애플리케이션 스크립트 내에서의 API 탐색기에서 작동하지만, 그러나 나는 얻을의 QuickBooks에 API를 사용하여 견적을 만들려고 해요 :

Error: Fetch failed, code: 400, message: {"Fault":{"Error":[{"Message":"Request has invalid or unsupported property","Detail":"Property Name:Unrecognized token 'Line': was expecting ('true', 'false' or 'null')\n specified is unsupported or invalid","code":"2010"}],"type":"ValidationFault"},"time":"2016-08-02T09:51:28.917-07:00"} (line 195, file "Tests") 

하지만 이유를 볼 수 없습니다 API는 "Line"키가 아닌 부울을 기대합니다.

var payload = { 

    "Line": [ 
     { 
     "Id": "3", 
     "LineNum": 1, 
     "Amount": 10, 
     "DetailType": "SalesItemLineDetail", 
     "SalesItemLineDetail": { 
      "ItemRef": { 
      "value": "2", 
      "name": "Hours" 
      }, 
      "UnitPrice": 10, 
      "Qty": 2 
     } 
     }, 
     { 
     "Amount": 10, 
     "DetailType": "SubTotalLineDetail", 
     "SubTotalLineDetail": {} 
     } 
    ],  
    "TxnTaxDetail": { 
     "TotalTax": 0 
    }, 
    "CustomerRef": { 
     "value": "1", 
     "name": "Mr Blobby" 
    }, 
    "CustomerMemo": { 
     "value": "Thank you for your business and have a great day!" 
    }, 
    "TotalAmt": 31.5, 
    "ApplyTaxAfterDiscount": false, 
    "PrintStatus": "NeedToPrint", 
    "EmailStatus": "NotSet", 
    } 

    var companyId = PropertiesService 
    .getUserProperties() 
    .getProperty('QuickBooks.companyId') 

    var url = 'https://quickbooks.api.intuit.com/v3/company/' + companyId + '/estimate' 

    var options = { 
    headers: { 
     'Accept': 'application/json' 
    }, 
    contentType: 'application/json', 
    method: 'post', 
    payload: payload, 
    muteHttpExceptions: true, 
    } 

    var service = OAuth1_.getService(); 

    var response = service.fetch(url, options) 
+0

당신은 우리에게 당신이 UrlFetchApp을 만들어 전체 전화를 게재 할 수 있습니까? –

+0

+ 디뮤 디자인 - 추가 가져 오기 –

답변

0

당신은 OAuth.fetch() 호출에 전달하기 전에 전체 페이로드를 캐릭터 라인 화해야합니다

이 내가 코드에서 POST 페이로드로 정의하는 방법이다.

그래서

var payload = JSON.stringify({ 
    "Line": [ 
    { 
     "Id": "3", 
     . 
     . 
}) 
관련 문제