"Bad request error" making API request.
Hi,
I'm making a request to an API that works perfectly with Postman, you can see it here:.png)
The URL is https://testcds.esriguide.org/v2/session/3189981 where the last part is the ID's session I want to get back.
When I try to make the same request in IRIS I always get a "Bad request" error.
I'm creating the request which all the information needed (or at least that I know):
Method TornaRequestGET() As %Net.HttpRequest
{
Set request = ##class(%Net.HttpRequest).%New()
Set request.SSLConfiguration = "iGUIDE"
Do request.SetHeader("Authentication",..#AuthenticationAPIKEY)
Do request.SetHeader("Accept","application/json")
Set request.HTTPVersion = "HTTP/2.0"
Set request.Https = 1
}
I make the request with:
..SendFormDataArray(.pHttpResponse, "GET", ..TornaRequestGET(), .pFormVarNames, .pData, pURL)
I always get the same error: "HTTP/1.1 400 Bad Request".
Can anyone help me please?
Thanks in advance.
Comments
This line is suspicious:
Set request.HTTPVersion = "HTTP/2.0"
%Net.HttpRequest works only with HTTP 1.0, 1.1, and the server replies with HTTP/1.1.
So, try not to set HTTPVersion
That was the problem! Thank you @Alexander Koblov for you help!