<Response [400]>, {u'errorCode': u'invalid.request.format.line-1.column-16'}

2 posts / 0 new
Last post
<Response [400]>, {u'errorCode': u'invalid.request.format.line-1.column-16'}

Hi all,
First time forum user. I hope somebody is able to help with the error code in my subject line?

, {u'errorCode': u'invalid.request.format.line-1.column-16'}

I'm getting this in response to trying to open a trade on a demo account using python. My code snippet is below:

order_header["VERSION"] = "2" #changes the version to 2
order_url = 'https://demo-api.ig.com/gateway/deal/positions/otc'
order_body = {
"epic": "IX.D.FTSE.DAILY.IP",
"expiry": "DFB",
"direction": "BUY",
"size": "1",
"orderType": "MARKET",
"level": None,
"guaranteedStop": "false",
"stopLevel": None,
"stopDistance": None,
"trailingStop": "false",
"trailingStopIncrement": None,
"forceOpen": "false",
"limitLevel": None,
"limitDistance": None,
"quoteId": None,
"currencyCode": "GBP"
order_response = requests.post(order_url, order_body, headers=order_header)
order_payload = order_response.json()
print (order_response, order_payload)

If anyone is able to shed light on exactly what line1 column16 is it would help me direct my troubeshooting more effectively.

Python seems to prefer None to the null shown in the API companion.

All help appreciated.



It may help others to know that in python requests, dictionary keys with a None value are not passed. To make my order_body stay in the recognised format for the API, it has to be turned into a JSON. This preserves the dictionary keys and gives them the null value.


order_response = requests.post(order_url, data=json.dumps(order_body), headers=order_header)

Log in or register to post comments