Hey Yus,
These are my investigations using
httpie(command line http).
First we need to create the file with the input:
$ echo "[624049117,2114097675]" > input.txt
Then I tested with a
GET to see what happens:
$ http --json --verbose "https://esi.evetech.net/latest/characters/affiliation/?datasource=tranquility"
GET /latest/characters/affiliation/?datasource=tranquility HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: application/json
Host: esi.evetech.net
User-Agent: HTTPie/2.2.0
HTTP/1.1 405 Method Not Allowed
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,Authorization,If-None-Match,X-User-Agent
Access-Control-Allow-Methods: POST,OPTIONS
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Type,Warning,ETag,X-Pages,X-ESI-Error-Limit-Remain,X-ESI-Error-Limit-Reset
Access-Control-Max-Age: 600
Allow: POST,OPTIONS
Connection: keep-alive
Content-Language: en-us
Content-Length: 30
Content-Type: application/json; charset=utf-8
Date: Thu, 15 Jul 2021 21:01:40 GMT
Strict-Transport-Security: max-age=31536000
Vary: Accept-Language
X-Esi-Error-Limit-Remain: 99
X-Esi-Error-Limit-Reset: 20
{
"error": "method not allowed"
}
So as you can see the
GET should give you a
405 Method Not Allowed and not an
OK like you reported.
Once you do a
POST with the data you provided:
$ http --json --verbose "https://esi.evetech.net/latest/characters/affiliation/?datasource=tranquility" < in.txt
POST /latest/characters/affiliation/?datasource=tranquility HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 23
Content-Type: application/json
Host: esi.evetech.net
User-Agent: HTTPie/2.2.0
[
624049117,
2114097675
]
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,Authorization,If-None-Match,X-User-Agent
Access-Control-Allow-Methods: POST,OPTIONS
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Type,Warning,ETag,X-Pages,X-ESI-Error-Limit-Remain,X-ESI-Error-Limit-Reset
Access-Control-Max-Age: 600
Allow: OPTIONS,POST
Connection: keep-alive
Content-Length: 156
Content-Type: application/json; charset=UTF-8
Date: Thu, 15 Jul 2021 21:02:08 GMT
Strict-Transport-Security: max-age=31536000
X-Esi-Error-Limit-Remain: 100
X-Esi-Error-Limit-Reset: 52
X-Esi-Request-Id: 648f51fa-e265-4765-8c5e-fd04ff48154e
[
{
"alliance_id": 1354830081,
"character_id": 2114097675,
"corporation_id": 98502318
},
{
"alliance_id": 99003581,
"character_id": 624049117,
"corporation_id": 98285865
}
]
The result is code
200 OK and then data is returned.
Side Note:
It's imperative that you have good debugging tools at your disposal when you're dealing with HTTP services.
You need to FIRST be sure of what the service needs in order to THEN do a good job in code.
httpie is a good command line tool if you like the CLI life.
There's also Postman if you're more into the GUI life.
Delphi also comes with a GUI client for this purpose, but after ~3 simple Google searches I couldn't find a link to it, sorry
As a principal rule of thumb when you're making a call to a service that deals in
JSON you should
AT LEAST include the following header:
http.AddHeader('Accept: application/json');
And if you're
POSTing any
JSON, then you should, also as a rule of thumb, include the following header:
http.AddHeader('Content-Type: application/json')
Only then can you be sure that you've made sure to adhere to the most basics of the specs in terms of any
JSON webservice.
Add those headers to your code and then tell us if anything changed.
Cheers,
Gus