25
Views
10
Comments
stringcontent and postAysnc rest APi

Dear All, Any Expert  how can we convert this to API rest consume call

    Client client = new Client();

            client.ClientName = ClientName;

            client.ClientSecret = ClientSecret;

            string jsonMessage = JsonConvert.SerializeObject(client);

            var content = new StringContent(jsonMessage, Encoding.UTF8, "application/json");


         HttpResponseMessage response = await httpClient.PostAsync("urlauthenticate", content);


2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi Aamir,

There is not enough information in  your question to help you.

This code uses a framework that exposes objects like Client and httpClient.

The actual REST service is not mentioned in your question.

To consume a REST API in OutSystems please read:

https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/REST/Consume_REST_APIs/Consume_one_or_more_REST_API_methods

or watch:

https://www.youtube.com/watch?v=gNyWIeJYfG0

Regards,

Daniel

2020-02-16 09-59-20
Aamir Hasan

Any one please

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Give more detailed information will get possible more replies

2020-02-16 09-59-20
Aamir Hasan

I need to get token, based on step what steps i will do based on c# code stringcontent in outsystems consume, 


i need to convert c# code in outsystems consume call

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

If you have working C# code you could also decide to create an OutSystems extension, cannot give you a better answer with the limited information you provide.

2020-02-16 09-59-20
Aamir Hasan

Simple how can i call about in outsystem rest api

Please find attached  i am getting error in outsystems, but when i run c# code above its working fine

error.PNG
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

In my first reply I already shared how you normally should consume a rest API in OutSystems, all you need is to load the swagger definition of the API and you are good.  The Image you provide shows no data that can helps to determine what is your problem. To get proper help  please think about sharing the relevant information to figure out what is the problem.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Aamir,

You should take a step back, and read the documentation for the REST service you are trying to consume, then use OutSystems to consume it.

You write you get an error in OutSystems, but include an image of an error in Postman. Are you sure you have the skills to do this project? Is there perhaps a more experienced colleague you can ask to help?

2021-09-21 07-24-50
Manikandan Pandian

Hi Aamir,
In OnBeforeRequest of Rest Api method, assign the json serialized string to RequestText and use post method.

2021-09-21 07-24-50
Manikandan Pandian

If you need utf-8 encoding you can use TextToBinary extension and then assign to RequestBinary.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.