How to Create a new Line using "\n " in any rest api?

106 views Asked by At

I am using Zoho Deluge Scripting to create an invoice in QuickBooks using both platforms Rest APIs.

I stuck at a place where I need to create line items descriptions as formatted on Zoho. Like descriptions in Zoho are multi-line and so when I fetch the line items from Zoho, it gives a "\n" where a new line is added in the product description in Zoho and when I try to update that same response in QuickBooks it gives below attached error. The sync works fine when I replace the "\n" with spaces. Does anyone know any trick how to solve these kind of API errors?

I have attached the API response and the code below:

LineDet.put("Description", item.get("product_description").replaceAll("\n", "\\\"\n"));

The API response is:

"Created Invoice":{
    "Fault":{
    "Error":[
    {
    "Message":"Request has invalid or unsupported property",
    "Detail":"Property Name:Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value\n specified is unsupported or invalid",
    "code":"2010"
    }
    ],
    "type":"ValidationFault"
    },
    "time":"2023-09-25T09:47:11.165-07:00"
    },

This is my Req Body :

    {
"Line":[
{
"DetailType":"SalesItemLineDetail",
"Amount":189,
"Description":"Color: Natural\nFront Side: Logo\nBack Side: None\n - Imprint: Full Color UV",
"SalesItemLineDetail":{
"UnitPrice":1.89,
"Qty":100,
"ItemRef":{
"name":null,
"value":"4"
}
}
},
{
"DetailType":"SalesItemLineDetail",
"Amount":45,
"Description":"Logo Set Up",
"SalesItemLineDetail":{
"UnitPrice":45,
"Qty":1,
"ItemRef":{
"name":null,
"value":"5"
}
}
},
{
"DetailType":"SalesItemLineDetail",
"Amount":20,
"Description":"Imprint Run Cost",
"SalesItemLineDetail":{
"UnitPrice":0.2,
"Qty":100,
"ItemRef":{
"name":null,
"value":"6"
}
}
},
{
"DetailType":"SalesItemLineDetail",
"Amount":0,
"Description":"Economy Shipping\n - Include Customer Packing Slip - \n\nShip 50pcs to x\nShip 50pcs to y",
"SalesItemLineDetail":{
"UnitPrice":0,
"Qty":1,
"ItemRef":{
"name":null,
"value":"7"
}
}
},
{
"DetailType":"SalesItemLineDetail",
"Amount":45.5,
"Description":"Factory Direct Drop Ship:",
"SalesItemLineDetail":{
"UnitPrice":45.5,
"Qty":1,
"ItemRef":{
"name":null,
"value":"8"
}
}
}
],
"CustomerRef":{
"value":"1"
},
"DueDate":"2023-08-18",
"CustomField":[
{
"DefinitionId":1,
"StringValue":"ECO09-145",
"Type":"StringType",
"Name":"Customer PO#"
},
{
"DefinitionId":2,
"StringValue":"2023-08-18",
"Type":"StringType",
"Name":"Delivery Date"
}
],
"CustomerMemo":{
"value":"08.10.23 - Test PO ,09.21.223 - PO Generated"
},
"Id":"35",
"SyncToken":"4",
"DocNumber":"N2230794-08"
}
0

There are 0 answers