Hallo Bbommel,
hab ich guck:
Delphi-Quellcode:
procedure TFormRESTTest.BtnRestAbwertenClick(Sender: TObject);
var
jValue, jApixResponse: TJSONValue;
jUpdates: TJSONArray;
hash : system.hash.THashSHA2;
Ammount, JsonString: string;
begin
memo.Clear;
Ammount:='-'+EDBetrag.Text;
if (AccountID<>'') and (AccountID<>'keine Karte') then
begin
JsonString:=JsonUpate(Ammount,AccountID,Sale);
Memo.lines.Add('-> '+JsonString);
Req_Update.Params.Clear;
Req_Update.AddBody(JsonString,ctNone);
Req_Update.Execute;
if Res_Update.StatusCode = 200 then
begin
jValue:=Res_Update.JSONValue;
Memo.lines.Add('<- '+ jValue.ToString);
jApixResponse:=jValue.GetValue<TJSONObject>('ApixResponse');
AccountInfo.AccountStatus:=jApixResponse.GetValue<Integer>('Status');
......
end
else
begin
ShowMessage('Fehler :'+inttostr(Res_Update.StatusCode));
Memo.lines.Add('<- '+ Res_Update.Content);
end;
end;
end;
Leider kommt: BadRequest. Der Server von denen ist zickig. Kann sein, dass er sich schon an den accept Headern stört.
Mit Req_Update.AddBody(JsonString,ctAPPLICATION_JSON); gehts auch nicht, da der Server den ContentType schon garnicht mag.
Wireshark erkennt auch das Json nicht richtig; sieht es so aus:
Code:
Hypertext Transfer Protocol
POST /ApiXRest/RestAPI/AccountPurses HTTP/1.1\r\n
Connection: Keep-Alive\r\n
Content-Type: application/x-www-form-urlencoded\r\n
Accept: application/json, text/plain; q=0.9, text/
html;q=0.8,\r\n
Accept-Charset: UTF-8, *;q=0.8\r\n
User-Agent: Embarcadero RESTClient/1.0\r\n
Content-Length: 580\r\n
Host:
api.countersolutions.com\r\n
\r\n
[Full request
URI: http://
api.countersolutions.com/ApiXRest/XXXXX/XXXXXX]
[HTTP request 1/1]
[Response in frame: 9]
File Data: 580 bytes
HTML Form
URL Encoded: application/x-www-form-urlencoded
Form item: "{"ApiXRequest":{"Hash":"b4909261182c6321d88e5e97dd53564bc7d9fa33fa809b61fd7ff3dda44428c5",".......
Key [truncated]: {"ApiXRequest":{"Hash":"b4909261182c6321d88e5e97dd53564bc7d9fa33fa809b61fd7ff3dda44428c5",......
Value: