The error:
{ "$type": "Nirvana.Data.TaskResultWebhook, V2API", "Headers": { "$type": "System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.String, mscorlib]], mscorlib", "Authorization": "Bearer \" & [GET Token].[service.getAccessToken] & \"", "Accept": "application/json" }, "Payload": "{\"Line\": [\"CustomerRef\": {\"value\": \"838\"}}", "Url": "https://sandbox-quickbooks.api.intuit.com/v3/company/*****************/invoice?", "Verb": "Post", "ContentType": "JSON", "MimeType": "application/json", "TimeoutSeconds": 180, "MaxRetryCount": 3, "AsyncExec": false, "AppErrors": { "$type": "Jeenee.DataTypes.AppErrors, Jeenee.DataTypes", "RecordInfo": false, "RecordWarning": true, "AnnotateErrors": false, "Errors": [ { "$type": "Jeenee.DataTypes.AppError, Jeenee.DataTypes", "Severity": 0, "ErrorCode": "ERROR_WORKFLOW_WEBHOOK_BODY_INVALID", "Description": "Failed to parse JSON due to After parsing a value an unexpected character was encountered: :. Path 'Line[0]', line 1, position 23.. Invalid JSON value starts with: : {\"value\": \"838\"}}", "DetailedErrorMessage": null, "TargetField": null, "LearnMoreUrl": null, "ComponentDescriptor": { "$type": "Jeenee.DataTypes.AppComponentDescriptor, Jeenee.DataTypes", "ComponentName": "BEHAVIOR_WORKFLOW", "EditorPropertyId": "ErrorPaneHeader", "SchemaPath": null, "OpenSchemaPath": null } } ] }, "TaskType": "Webhook", "TaskName": "POST_Invoice_QBO" }
The template:
{ "Line": [ <<Start: [Related ServiceLOGs]>> { "DetailType": "SalesItemLineDetail", "Amount": <<DECIMAL([TSPrice])>>, "SalesItemLineDetail": { "ItemRef": { "name": "<<[Service]>>", "value": "<<NUMBER([SrvcID].[QBSrvcID])>>" } } } ], <<End>> "CustomerRef": { "value": "<<NUMBER([ShopID].[QBShopID])>>" } }
The Observation:
// I used the generated template to format this part to find all the services related to the invoice and add the listed line items parameters to be posted to quickbooks.
I have an app script that can successfully perform this action but only handles one line item.
Using intuit developer api explorer i figured i should be able to accomodate all the services by going with the webhook and referencing related services with the <<Start: [Related Services]>> template expression to append the parameters in reference to each line item related to the invoice that is triggered when an assignment's status is set to finalized.
I am positive it is just in how the " mark is not being escaped correctly on my end but I thought i was doing it correctly as described in Call a webhook from an automation
[MALFORMED]
// AppSheet is adding in \ causing a syntax error to trigger and is ignoring the <<Start:End>> Template expression to loop and populate the related services (line items) parameters i need to extract in order to successfully POST and invoice to QuickBooks.
"Payload": "{\"Line\": [\"CustomerRef\": {\"value\": \"###\"}}",โ
[ORIGINAL]
"Payload":{ "Line": [ <<Start: [Related ServiceLOGs]>> { "DetailType": "SalesItemLineDetail", "Amount":<<DECIMAL([TSPrice])>>, "SalesItemLineDetail":{ "ItemRef":{ "name":"<<[Service]>>", "value":"<<NUMBER(SrvcID].[QBSrvcID])>>" } } } <<End>> ], "CustomerRef":{ "value":"<<NUMBER([ShopID].[QBShopID])>>" } }โ
[DESIRED TEMPLATE TRANSLATION FOR POST PAYLOAD (REQUEST BODY)]
"Payload": { "Line":[ //Line Item1 {"DetailType":"SalesItemLineDetail","Amount": $$$.$$, "SalesItemLineDetail":{"ItemRef":{"name":"FOO","value":"###"}}}, //Line Item2 {"DetailType":"SalesItemLineDetail","Amount":$$$.$$, "SalesItemLineDetail":{"ItemRef":{"name": "BAR","value": "###"}}}], "CustomerRef":{"value": "###"} }
Solved! Go to Solution.
I've never even thought to use any expression in the headers config, interesting!
I did some experimenting, and it's very odd how it works*, but I found that this format seems to work:
Authorization:"Basic " & [script].[val]
Or translated to your case:
Authorization:"Bearer " & [GET Token].[Service.getAccessToken]
*Edit: I just realized how it works (or at least I think). If you leave out the colon, it throws an error to that effect. Meaning its expects a certain structure in that field: a header name, followed by a colon, then followed by a value. That value can be generated by an expression. Typically, that expression is simply a quoted text string. The quotes you use for that, are not the final quotes in the generated header, even though from test page they look the same and are in the same spot. (check out the header result in the monitor instead, it shows a slightly different end result) Basically, it's automatically assigning the quotes where needed around the header/value, you don't need to provide them. So you just need to generate the value, which is the hard-coded text string "Bearer " concatenated with the script's return value.
User | Count |
---|---|
16 | |
15 | |
4 | |
3 | |
2 |