ItsPeter
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Community Tutorials
Store
Posts posted by ItsPeter
-
-
Hi. I'm trying to figure out how to close the order via API on my demo account and I'm stuck. From what I was able to research, I have to use "_method: DELETE" header with POST, but doing so results with no response at all or invalid.request.format.line-2.column-51, depending on the approach.
Here's the cURL part of the code:
No response:$ch = curl_init($connection_url);
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=UTF-8',
'Accept: application/json; charset=UTF-8',
'X-IG-API-KEY: '.$key.'',
'Version: 1',
'Authorization: Bearer '.$access_token.'',
'IG-ACCOUNT-ID: '.$account_id.'',
'_method: DELETE'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$tokens = curl_exec($ch);
'Invalid request' response:
$ch = curl_init($connection_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=UTF-8',
'Accept: application/json; charset=UTF-8',
'X-IG-API-KEY: '.$key.'',
'Version: 1',
"Authorization: Bearer $access_token",
'IG-ACCOUNT-ID: '.$account_id.'',
'_method: DELETE',
));
$tokens = curl_exec($ch);
Any help would be greatly appreciated.
API - PHP - Post with _method: DELETE
in IG Technical Support - Platform and App Help
Posted
Hi,
I figured it out, here's the code for BUY position if anyone else struggles with the same problem, amend values relevant to your open positions: