Accessing REST API lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Chris · 2021-12-05 09:23 Hi I'm trying to access a REST API with the following code, but keep getting this response HttpMessageNotReadableError","code":400,"error_message":"Required request body is missing, and I can't work out why. When I direct the URL to a socket testing program running locally it looks like the connection is being closed before the json data is sent. Any help or suggestions would be gratefully received.  procedure TForm1.Button2Click(Sender: TObject); const url = 'https://api.textanywhere.com/API/v1.0/REST/sms'; var   postJson: TJSONObject;   responseData: String; begin   postJson := TJSONObject.Create;   postJson.Add('message_type', 'GP');   postJson.Add('message', 'Test message');   postJson.Add('recipient','[+44]');   postJson.Add('sender', 'XX');   postJson.Add('scheduled_delivery_time', '20211223101010');   postJson.Add('order_id', '12344');   postJson.Add('returnCredits', true);   With TFPHttpClient.Create(Nil) do   try     AddHeader('Content-Type', 'application/json');     AddHeader('Connection', 'Keep-Alive');     AddHeader('user_key',key);     AddHeader('session_key',session);     RequestBody := TStringStream.Create(postJson.AsJSON);     responseData := Post(url);   finally    Free;   end; memo1.Lines.Add(responseData); end; ---------------------------------------------------------------------- paweld · 2021-12-05 09:51 recipients you must pass as an array: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button2Click(Sender: TObject);const   url = 'https://api.textanywhere.com/API/v1.0/REST/sms';var  postJson: TJSONObject;  reciparr: TJSONArray;  responseData: String;begin  postJson := TJSONObject.Create;  postJson.Add('message_type', 'GP');  postJson.Add('message', 'Test message');  reciparr := TJSONArray.Create;  reciparr.Add('+44 phone number'); //add another phone number: reciparr.Add('another phone number');  postJson.Add('recipient', reciparr);                 postJson.Add('sender', 'XX');  postJson.Add('scheduled_delivery_time', '20211223101010');  postJson.Add('order_id', '12344');  postJson.Add('returnCredits', true);  with TFPHttpClient.Create(Nil) do  try    AddHeader('Content-Type', 'application/json');    AddHeader('Connection', 'Keep-Alive');    AddHeader('user_key', key);    AddHeader('session_key', session);    RequestBody := TStringStream.Create(postJson.AsJSON);    responseData := Post(url);  finally   Free;  end;  memo1.Lines.Add(responseData);end; ---------------------------------------------------------------------- Chris · 2021-12-05 10:41 Thanks paweld, I just tried that but still get the same error.