Post request with parameters

2»

Answers

  • KalelKalel Posts: 4Member
    You can do POST request by using my this code:

    Parameters
    9donpyp2ot7d.png

    Local Variables
    5kakj16pwyb8.png

    CallRESTWebService(BaseUrl : Text;Method : Text;RestMethod : Text;VAR HttpContent : DotNet "System.Net.Http.HttpContent";VAR HttpResponseMessage : DotNet "System.Net.Http.HttpResponseMessage")
    
    HttpClient := HttpClient.HttpClient();
    HttpClient.BaseAddress := Uri.Uri(BaseUrl);
    
    CASE RestMethod OF
      'GET':    
        HttpResponseMessage := HttpClient.GetAsync(Method).Result;
      'POST':   
        HttpResponseMessage := HttpClient.PostAsync(Method,HttpContent).Result;
      'PUT':    
        HttpResponseMessage := HttpClient.PutAsync(Method,HttpContent).Result;
      'DELETE': 
        HttpResponseMessage := HttpClient.DeleteAsync(Method).Result;
    END;
    
    


    Explanation of the parameters

    BaseUrl – the first part of the url that is being called, e.g.: http://www.google.com/

    Method – the resource on the web service, in other words, the second part of the url, e.g. somecoolapi/parameter?option=value

    RestMethod – one of the request verbs, either GET, POST, PUT or DELETE

    HttpContent – the content to be sent with the POST or PUT command

    HttpResponseMessage – the response message containing the status code and the response body. This parameter is ByVar because the calling code needs to handle the specific response itself. That’s not part of the generic pattern.



    You have to put your data in HttpContent because you are using POST method. This is the correct way of sending parameters via post.

    Como ingreso mi blob en un http content?
  • jacksoncharliejacksoncharlie Posts: 11Member
    Thank you, I'll try this solution and will let you know about it's result.
Sign In or Register to comment.