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": "###"}
}
