HTTp to REST without response

AitorEGAitorEG Posts: 290Member
Hi everyone,

I'm sending a file to a Rest WebService, in this way:
HttpWebRequest := HttpWebRequest.Create('http://eshop.xxxxx-eu.com/ws/api/rest');
 HttpWebRequest.Method := 'POST';
 HttpWebRequest.ContentType('application/x-www-form-urlencoded');
 postString := STRSUBSTNO('json=%1',pJson);
 StreamWriter := StreamWriter.StreamWriter(HttpWebRequest.GetRequestStream);
  StreamWriter.Write(postString);
  StreamWriter.Close;
  StreamWriter.Dispose;
  HttpWebRequest.GetResponse;
But I'mn getting an error in the WebResposne, becasue the server is not responding anything. How can i "run" the request without expecting any response?

Thank you very much

Answers

  • ShaiHuludShaiHulud Posts: 42Member
    You could put the HttpWebRequest.GetResponse into a TryFunction. That way even if it fails, you can continue.

    However, how would the server send no response? There must be at least basic (OK (Response Code 200)) response, even if there's nothing in the response body.
    Arturas Kulsinskas
    NaviLogic
  • RobyRRobyR ItalyPosts: 39Member
    I tried to connect to that URI with a browser and I can't reach the server, are you sure your API is accessible?
  • AitorEGAitorEG Posts: 290Member
    RobyR wrote: »
    I tried to connect to that URI with a browser and I can't reach the server, are you sure your API is accessible?
    The URI I've wrote obviously is not the real, is from one of our customer's URL.... ;-). Thanks anyway
  • AitorEGAitorEG Posts: 290Member
    ShaiHulud wrote: »
    You could put the HttpWebRequest.GetResponse into a TryFunction. That way even if it fails, you can continue.

    However, how would the server send no response? There must be at least basic (OK (Response Code 200)) response, even if there's nothing in the response body.

    I know it has no sense, so after talking to the provider, they've changed the servie to get a response, and the problem finally is solved
Sign In or Register to comment.