Body parameter key mapping to a nested array of key:value pairs

how can I configure the body of my POST to match the following example with nested Array of Key:Value pairs?

POST /v3/company/4620816365270944390/invoice?minorversion=65

Content type:application/json
Production Base URL:https://quickbooks.api.intuit.com
Sandbox Base URL:https://sandbox-quickbooks.api.intuit.com

{
"Line": [
{
"DetailType": "SalesItemLineDetail",
"Amount": 100.0,
"SalesItemLineDetail": {
"ItemRef": {
"name": "Rental Income",
"value": "1"
}
}
}
],
"CustomerRef": {
"value": "1"
}
}

How about sending the raw JSON as the body of your post instead of as parameters?

1 Like

Should work great that way, now I get an error 500 for Content type
here is what I en


tered as Raw:

"Line": [
{
"DetailType": "SalesItemLineDetail",
"Amount": "100.0",
"SalesItemLineDetail": {
"ItemRef": {
"name": "Rental Income",
"value": "1"
}
}
}
],
"CustomerRef": {
"value": "1"
}

Here is the request sent

{
"request": {
"url": "https://sandbox-quickbooks.api.intuit.com/v3/company/(mycompanyNumber)/invoice?content-type=application%2Fjson&minorversion=65",
"method": "POST",
"body": " "Line": [\n {\n "DetailType": "SalesItemLineDetail", \n "Amount": "100.0", \n "SalesItemLineDetail": {\n "ItemRef": {\n "name": "Rental Income", \n "value": "1"\n }\n }\n }\n ], \n "CustomerRef": {\n "value": "1"\n }",
"headers": {
"User-Agent": "Retool/2.0 (+https://docs.tryretool.com/docs/apis)",
"Accept": "application/json",
"Authorization": "Bearer (my bearer token)",
"X-Retool-Forwarded-For": "66.198.197.223",
"x-datadog-trace-id": "1441991186746698037",
"x-datadog-parent-id": "2528882375111266953",
"x-datadog-sampling-priority": "0",
"ot-baggage-requestId": "undefined"
}
},
"response": {
"data": {
"Fault": {
"Error": [
{
"Message": "Unsupported Operation",
"Detail": "Operation Cannot consume content type is not supported.",
"code": "500"
}
],
"type": "ValidationFault"
},
"time": "2023-02-01T13:43:49.901-08:00"
},
"headers": {
"date": [
"Wed, 01 Feb 2023 21:43:49 GMT"
],
"content-type": [
"application/json"
],
"content-length": [
"201"
],
"connection": [
"keep-alive"
],
"intuit_tid": [
"(my intuit ID)"
],
"x-spanid": [
"9d04b928-74bd-4e33-9d79-27c8d9dc1823"
],
"x-amzn-trace-id": [
"Root=1-63dadd15-2a46edea41ed31ad36956d1d"
],
"x-content-type-options": [
"nosniff"
],
"x-envoy-upstream-service-time": [
"68"
],
"strict-transport-security": [
"max-age=31536000"
],
"server": [
"envoy"
]
},
"status": 400,
"statusText": "Bad Request"
}
}

Nevermind, It works great. the issues were:

  1. as you solved for me in another post the content type key needs to have a dash and a capital C "Content-type"
  2. Quickbooks online will not accept a duplicate invoice for the same customer on the same day for the same amount, while playing with the sample company I have to change the invoice amount each time I submit to create a new invoice.

Thanks,
Nate