Skip to content
Advertisement

Printing sales order doesnt work with exact online

I am trying to print a sales order with a known OrderId however it throws an error which I haven’t been able to debug.

printest = {
  "OrderId" : "0b28a174-524d-4fe3-b763-6b594d24afaa",
  "DocumentLayout" : "78aabba4-dbc5-416a-bb09-51aeca8dfd5d"
}

headers = {
        'Accept': 'application/json',  
        'Content-Type': '*/*',
        'Prefer': 'return=representation'
}

test = requests.post("https://start.exactonline.nl/api/v1/[division]/salesorder/PrintedSalesOrders",headers=headers, data=printest)
test.json()

error is:

{'error': {'code': '',
  'message': {'lang': '',
   'value': "Error reading syndication item: 'Data at the root level is invalid. Line 1, position 1.'."}}}

What is the problem here? Please help

Advertisement

Answer

It turns out you need to use the json argument instead of using data.

This

requests.post("url",headers=headers, data=printest)

becomes

requests.post("url",headers=headers, json=printest)

Content-Type header can be set as application/json

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement