Getting this error: Unexpected token ':'

I have tried to figure this out in Postman and also searched the forum but without luck. Still having this SyntaxError: Unexpected token ‘:’. Still when sending this PUT I get success: True. Maybe this error does’nt matter? I am not sure but I am fairly new to Postman. Any help appreciated.

I selected PUT, Body, Raw and JSON.

Here is the code

{
“IssueDate”: “2022-04-29”,
“DueDate”: “Net”,
“DueDateDays”: null,
“DueDateDate”: null,
“Reference”: “2011”,
“QuoteNumber”: null,
“OrderNumber”: null,
“Customer”: “2b279373-f46e-4397-9c13-16a4a5f4c48d”,
“SalesQuote”: null,
“SalesOrder”: “b4556c0c-ca04-49df-86c2-fd0b8e611579”,
“BillingAddress”: “Road 95\n999999-9999”,
“Description”: null,
“Lines”: [
{
“Item”: “ed0ecf26-39f4-4b1b-b74d-e0f7c2d6032e”,
“Account”: null,
“CapitalAccount”: null,
“SubAccount”: null,
“SpecialAccount”: null,
“FixedAsset”: null,
“IntangibleAsset”: null,
“LineDescription”: null,
“CustomFields”: null,
“Qty”: 6.0,
“SalesUnitPrice”: 1600.0,
“CurrencyAmount”: 0.0,
“DiscountPercentage”: 0.0,
“DiscountAmount”: 0.0,
“TaxCode”: “e57a094f-de41-448c-b7a6-d6327029213c”,
“Project”: null,
“Division”: “dd2f413d-7b3c-44aa-9d42-5c89717bccb0”
},
{
“Item”: “97f444f5-d841-4869-9b25-b37fe3d515cf”,
“Account”: null,
“CapitalAccount”: null,
“SubAccount”: null,
“SpecialAccount”: null,
“FixedAsset”: null,
“IntangibleAsset”: null,
“LineDescription”: null,
“CustomFields”: null,
“Qty”: 11.0,
“SalesUnitPrice”: 220.0,
“CurrencyAmount”: 0.0,
“DiscountPercentage”: 0.0,
“DiscountAmount”: 0.0,
“TaxCode”: null,
“Project”: null,
“Division”: null
}
],
“SalesInventoryLocation”: null,
“HasLineNumber”: true,
“HasLineDescription”: false,
“Discount”: false,
“DiscountType”: “Percentage”,
“AmountsIncludeTax”: false,
“Rounding”: true,
“RoundingMethod”: “RoundDown”,
“WithholdingTax”: false,
“WithholdingTaxType”: “Rate”,
“WithholdingTaxPercentage”: 0.0,
“WithholdingTaxAmount”: 0.0,
“EarlyPaymentDiscount”: false,
“EarlyPaymentDiscountType”: “Percentage”,
“EarlyPaymentDiscountRate”: 0.0,
“EarlyPaymentDiscountAmount”: 0.0,
“EarlyPaymentDiscountDays”: null,
“LatePaymentFees”: false,
“LatePaymentFeesPercentage”: 0.0,
“TotalAmountInWords”: false,
“TotalAmountInBaseCurrency”: false,
“Bilingual”: false,
“CustomTitle”: false,
“SalesInvoiceCustomTitle”: null,
“HasSalesInvoiceCustomTheme”: false,
“SalesInvoiceCustomTheme”: null,
“AutomaticReference”: false,
“HideDueDate”: true,
“HideBalanceDue”: false,
“ClosedInvoice”: false,
“OldLayout”: false,
“ShowTaxAmountColumn”: false,
“HasSalesInvoiceFooters”: false,
“SalesInvoiceFooters”: null,
“CustomFields”: {
“7ba04828-30a3-40e5-bb0b-c87ebc478f20”: “Test”,
“7f00ce21-6c9e-42b1-bd3a-4f313a9043c7”: “No”
}
}

I plugged this into a postman request, the only issue I see with is is the character you’re using for quotations. I replaced them all with " and it accepted it as a valid json object.

I don’t know why the quotation looks different here in the forumpost, but if I copy directly from Postman line 2 of the code the quotation looks fine or like " but when I post the comment in the forum then it changes, see below.

Code line 2 pasted into Postman: “IssueDate”: “2022-04-23”,

as a comparison, this is quotation typed into Postman and then copied to this comment: "

I changed with replace all the quotation marks in Postman but still the same syntax error

If I simplify the code, see below, I still get the syntax error. The quotation and colon I typed into Postman so there should not be any “paste” contamination

{
“IssueDate”: “2022-04-23”,
}

Also tried this setting for the Header but the error is still in place

016950-Postman

I also ran the code through Beautify just in case but still the error

Hi

The " issue is simply a copy and paste thing. Had this loads of times, this forum uses different text formatting. Good to be aware of this, a simple find all and replace will fix that as mentioned above.

The JSON itself passes as valid so not really sure


Could you screenshot the actual error you see??
Or copy in the console output??

:+1:

image

this is from the console

This Javascript “snippet” is given alongside the code on the source page where I got the JSON code. Don’t know if this is also needed in Postman for the JSON code to work without error?

fetch(‘https://kamipdf.manager.io/api/X19fX19fX0Jha2VyeSB2MTAgdixncnMgUFVU/ad12b60b-23bf-4421-94df-8be79cef533e/7483730c-21f2-408e-adb2-59f44563b845.json’, {
method: ‘PUT’,
body: document.getElementsByTagName(‘textarea’)[0].value
})
.then(response => response.json())
.then(data => console.log(JSON.stringify(data, null, 2)));

Can you screenshot or copy paste the code from your tests tab?

This is from the Test tab

{
“SalesInventoryLocation”: null,
“HasLineNumber”: false,
“HasLineDescription”: false,
“Discount”: false,
“DiscountType”: “Percentage”,
“AmountsIncludeTax”: false,
“Rounding”: true,
“RoundingMethod”: “RoundDown”,
“WithholdingTax”: false,
“WithholdingTaxType”: “Rate”,
“WithholdingTaxPercentage”: 0.0,
“WithholdingTaxAmount”: 0.0,
“EarlyPaymentDiscount”: false,
“EarlyPaymentDiscountType”: “Percentage”,
“EarlyPaymentDiscountRate”: 0.0,
“EarlyPaymentDiscountAmount”: 0.0,
“EarlyPaymentDiscountDays”: null,
“LatePaymentFees”: false,
“LatePaymentFeesPercentage”: 0.0,
“TotalAmountInWords”: false,
“TotalAmountInBaseCurrency”: false,
“Bilingual”: false,
“CustomTitle”: false,
“SalesInvoiceCustomTitle”: null,
“HasSalesInvoiceCustomTheme”: false,
“SalesInvoiceCustomTheme”: null,
“AutomaticReference”: false,
“HideDueDate”: true,
“HideBalanceDue”: false,
“ClosedInvoice”: false,
“OldLayout”: false,
“ShowTaxAmountColumn”: false,
“HasSalesInvoiceFooters”: false,
“SalesInvoiceFooters”: null,
“CustomFields”: {
“7ba04828-30a3-40e5-bb0b-c87ebc478f20”: “HĂ©r default texti sem editable ie gjalddagi/eindagi eftir 7d\n{{ fields["Invoice date"] }}”,
“7f00ce21-6c9e-42b1-bd3a-4f313a9043c7”: “Nei”
}

Ok, so why is this in the test tab?

This would fail as it’s not JavaScript, it’s just JSON. This is likely where the invalid syntax is triggering.

Comment out this JSON or delete it and try again.

{
“SalesInventoryLocation”: null,
“HasLineNumber”: false,
“HasLineDescription”: false,
“Discount”: false,
“DiscountType”: “Percentage”,
“AmountsIncludeTax”: false,
“Rounding”: true,
“RoundingMethod”: “RoundDown”,
“WithholdingTax”: false,
“WithholdingTaxType”: “Rate”,
“WithholdingTaxPercentage”: 0.0,
“WithholdingTaxAmount”: 0.0,
“EarlyPaymentDiscount”: false,
“EarlyPaymentDiscountType”: “Percentage”,
“EarlyPaymentDiscountRate”: 0.0,
“EarlyPaymentDiscountAmount”: 0.0,
“EarlyPaymentDiscountDays”: null,
“LatePaymentFees”: false,
“LatePaymentFeesPercentage”: 0.0,
“TotalAmountInWords”: false,
“TotalAmountInBaseCurrency”: false,
“Bilingual”: false,
“CustomTitle”: false,
“SalesInvoiceCustomTitle”: null,
“HasSalesInvoiceCustomTheme”: false,
“SalesInvoiceCustomTheme”: null,
“AutomaticReference”: false,
“HideDueDate”: true,
“HideBalanceDue”: false,
“ClosedInvoice”: false,
“OldLayout”: false,
“ShowTaxAmountColumn”: false,
“HasSalesInvoiceFooters”: false,
“SalesInvoiceFooters”: null,
“CustomFields”: {
“7ba04828-30a3-40e5-bb0b-c87ebc478f20”: “HĂ©r default texti sem editable ie gjalddagi/eindagi eftir 7d\n{{ fields["Invoice date"] }}”,
“7f00ce21-6c9e-42b1-bd3a-4f313a9043c7”: “Nei”
}

@w4dd325, I deleted it and it solved the error. Thank you very much. I must have accidentally pasted this code in the Test tab when I thougt I was in the Body tab. Typical rookie mistake :slight_smile:

Excellent, glad it’s sorted!