Issue using invoke code API

I have this API invoked into a c# code block. I have the web api package installed with the imports of Restapi, restsharp.authentication, restsharp, restsharp.authentication.oauth, newtonsoft.json and newtonsoft.json.linq

var options = new RestClientOptions("https://URL")
  MaxTimeout = -1,
var client = new RestClient(options);
var request = new RestRequest("/EndPoint", Method.Get);
request.AddHeader("Accept", "Accept header");
request.AddHeader("Authorization", "Bearer Token");
RestResponse response = await client.ExecuteAsync(request);

But I am getting this error

Can anyone help?

@ppr @Anil_G @supermanPunch would you guys please be able to take a look? would appreciate some help if you could :slight_smile:

Hi @aquinn ,

Could you maybe try installing the UiPath.WebAPI.Activities package and check if the error resists ?

I already have this installed and updated, thanks though! its weird as this call was created in postman and they used to work with UiPath but i think im missing an import or something


Can you please try this please

async System.Threading.Tasks.Task MakeRequestAsync()
    var client = new RestClient("https://URL");
    client.Timeout = -1;
    var request = new RestRequest("/EndPoint", Method.GET);
    request.AddHeader("Accept", "Accept header");
    request.AddHeader("Authorization", "Bearer Token");

    IRestResponse response = await client.ExecuteAsync(request);


Looks like restclientoptions is missing …so used another method…

Hope this helps


Thank you!!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.