I am writing a mobile application for Android on Delphi 10. My program sends a post and get requests using the THTTPClient component. The script on the server accepts requests in the format, so when sending a request, you must specify in the header "Content Type: application / json". The fact is that I can't change the Content Type. When you send a Get request, it will change, but when you send a Post request, it will not. I use about this code:
procedure ThomeForm.Button1Click(Sender: TObject); var data: TStringList; H: THTTPClient; begin data := TStringList.Create; data.Add('{"phone":"' + HomeForm.Phone.Text + '"}'); h := THTTPClient.Create; h.ContentType := 'application/json'; h.Accept := 'application/json, text/plain, */*'; log.Text := h.Post('https://site.ru/api/phone', data).ContentAsString(); end; Why does this happen and how to fix it?
CustomHeadersto enter? Between "accepts json requests" and "it is necessary to specify the" link " therefore " is not very correct. In general, there is usually no such duty, but the server as a whole can filter requests by this header. - teran