RestClient' is ambiguous, imported from 'UiPath.Web, RestSharp' namespaces or types uipath

Hello friend,

I’m using the following code:

Dim client As RestClient = New RestClient("https://apimxxxxxxxx")
client.Timeout = 10000
Dim request As RestRequest= New RestRequest(Method.POST)
request.AddHeader("Content-Type", "fihier/pdf")
request.AddParameter("fichier/pdf", File.ReadAllBytes( fichier), ParameterType.RequestBody)
 Dim response As IRestResponse = client.Execute(request)
 Console.WriteLine(response.Content)

I got the error:
erreur BC30561 : ‘RestClient’ est ambigu, importé des espaces de noms ou des types ‘UiPath.Web, RestSharp’. À la ligne 1
erreur BC30561 : ‘RestClient’ est ambigu, importé des espaces de noms ou des types ‘UiPath.Web, RestSharp’. À la ligne 1
erreur BC30561 : ‘Method’ est ambigu, importé des espaces de noms ou des types ‘UiPath.Web, RestSharp’. À la ligne 3

Dependencies:
image

Restsharp imported:

image

Hi @abdel

Try to downgrade the RestSharp dependence version 106.10.1 and try with the below code

Dim client As RestSharp.RestClient = New RestSharp.RestClient("https://apimxxxxxxxx")
client.Timeout = 10000
Dim request As RestRequest= New RestRequest(RestSharp.Method.POST)
request.AddHeader("Content-Type", "fihier/pdf")
request.AddParameter("fichier/pdf", File.ReadAllBytes( fichier), ParameterType.RequestBody)
Dim response As IRestResponse = client.Execute(request)
Console.WriteLine(response.Content)

Regards
Gokul

I tryed to change the version to 106.10.1 :

but in studio the version swith automatically to 106.15.0

image

i didt know why

Hi @abdel

  • Try to re install the uipath studio
  • Try to reinstall the package.

Regards
Gokul

Hi @Gokul001,

If your call returns a response, how do you write the code to do this? My http call returns an ID from this response. Your code works great, I just need to know how to code an out argument to return the id written in the Console.WriteLine(reponse.Content) line. Any suggestions are greatly appreciated.

Kyle

Figured it out. I added an in/out argument as string and added this to your code.
out_response = response.Content

After that I desearlizsed json like normal to parse my id out. Again appreciate your code.