Jump to content

KML

Community Member
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

KML's Achievements

Occasional Contributor

Occasional Contributor (2/10)

1

Reputation

  1. Thanks! 🙂 Tested and works with version 1. I sort of remember that I changed to version 2 a few months back, but I don't remember why, and the program still seems to work. (That code is also used during log in and creation of position.) Not sure why that lead to 404, but now I'm past that hurdle.
  2. Where you able to get this to work? When I add the _method = DELETE header, I get a 404 file not found, but I've checked the URI about 718 times. I'm able to create new positions, and also to delete using the API companion. The following is a printout from my post() method when creating a position: IgAPI.post: URI: https://demo-api.ig.com/gateway/deal/positions/otc IgAPI.post: Headers: java.net.http.HttpHeaders@2c272c73 { {Accept=[application/json; charset=UTF-8], Content-Type=[application/json; charset=UTF-8], CST=[removed], IG-ACCOUNT-ID=[removed], Version=[2], X-IG-API-KEY=[removed]} } IgAPI.post: Body: {"currencyCode":"USD","direction":"BUY","epic":"IX.D.SPTRD.IFM.IP","expiry":"-","forceOpen":"true","guaranteedStop":"false","orderType":"MARKET","size":"0.04","stopDistance":"2","trailingStop":"true","trailingStopIncrement":"1"} which works. And the following is the same printout when trying to delete a position: IgAPI.post: URI: https://demo-api.ig.com/gateway/deal/positions/otc IgAPI.post: Headers: java.net.http.HttpHeaders@42f3e43d { {_method=[DELETE], Accept=[application/json; charset=UTF-8], Content-Type=[application/json; charset=UTF-8], CST=[removed], IG-ACCOUNT-ID=[removed], Version=[2], X-IG-API-KEY=[removed]} } IgAPI.post: Body: {"dealID":"DIAAAAPN7BCT8AP","direction":"SELL","size":"0.04","orderType":"MARKET"} which yields a 404 response. Any help highly appreciated!
  3. Thanks for all your replies! Highly appreciated! 🙂 However, I'm still not able to cross the finish line. If I proved the following headers: {_method=[DELETE], Accept=[application/json; charset=UTF-8], Content-Type=[application/json; charset=UTF-8], CST=[removed], IG-ACCOUNT-ID=[removed], Version=[2], X-IG-API-KEY=[removed]} I get the 404 File not found error. However, when I use the following headers: {Accept=[application/json; charset=UTF-8], Content-Type=[application/json; charset=UTF-8], CST=[removed], IG-ACCOUNT-ID=[removed], Version=[2], X-IG-API-KEY=[removed]} I get {"errorCode":"validation.null-not-allowed.request.expiry"} which is expected as I don't provide sufficient information to create a new position. (I guess that is what IG thinks I'm trying to do when I don't add the _method= DELETE? Any ide what I'm missing/misunderstanding? I still have the option to delete a position by creating a new with a opposite buy/sell attribute, but it would feel more satisfying making this work. 🙂
  4. Dear all, I'm having trouble deleting a position using the API. As I understand https://labs.ig.com/rest-trading-api-reference/service-detail?id=678, I'm supposed to send a DELETE request with a body. But isn't a DELETE-request supposed to be without a body? The line HttpRequest request = HttpRequest.newBuilder().uri(URI.create(uri)) .headers("Content-Type", "application/json; charset=UTF-8", "Accept", "application/json; charset=UTF-8", "Version", "2", "IG-ACCOUNT-ID", CAI, "X-IG-API-KEY", APIKEY, "CST", CST) .method("DELETE", HttpRequest.BodyPublishers.ofString(body)) .build(); returns a 404 not found error, but if I change DELETE to POST as in HttpRequest request = HttpRequest.newBuilder().uri(URI.create(uri)) .headers("Content-Type", "application/json; charset=UTF-8", "Accept", "application/json; charset=UTF-8", "Version", "2", "IG-ACCOUNT-ID", CAI, "X-IG-API-KEY", APIKEY, "CST", CST) .method("POST", HttpRequest.BodyPublishers.ofString(body)) .build(); I get an expected error {"errorCode":"invalid.request.format.line-1.column-3"}. Does this mean that I'm supposed to use the POST method anyway? How does it then know that I',m deleting the position and not creating a new one? I could of course delete a long position by creating a short position and vice versa, but that looks a bit messier. Thanks for any help or clarifications.
  5. Thanks for your input. I started to code from scratch, using JDK 11 on Linux. That is, I did not start with the code from Githup. Not sure what you mean by default profile, but I had to create a specific username/password for the application in addition to the one I use when I log in myself. As the user interface in Norwegian, I'm not sure on the exact wording in the menues, but the link is https://www.ig.com/no/myig/settings/api-keys. Not that there are different entries for live and demo accounts. The application uses the same username/password as I do in the API companion.
  6. Any progress? I just noted that when I omit the search term (ie calls https://demo-api.ig.com/gateway/deal/markets, I get a different error message, "Service bean method[getMultipleMarketDetailsV1] failure: null". And then I also get the exact same error message testing the API companion. Also the http status changed from 401 to 500.
  7. Dear all. I'm playing around with the API using Java. I've been able to log in (version 1), listing accounts (https://demo-api.ig.com/gateway/deal/accounts), listed top level nodes (marketnavigation) and subscribed to some information using the LightStreamer client. However, I'm now trying the /markets endpoint, but with no success so far. For instance, I get status 401, with error code "error.better-search.invalid-call". I'm not able to find this error message in the documentation. The same endpoint work when I try the API companion. Any help highly appreciated!
×
×
  • Create New...
us