Http Request Header (Uploading Files through PATCH method)

Hi All,

Dim client As RestSharp.RestClient = New RestSharp.RestClient (“https://xxxxxx/customers/1234/people/123/fields/xxxxx/binary”)
client.Timeout = 10000
Dim request As RestRequest= New RestRequest(RestSharp.Method.PATCH)
request.AddHeader(“Authorization”,“Bearer xxxxxxxxxx”)
request.AddHeader(“Content-Type”, “multipart/form-data;”)
request.AddParameter(“text/pdf”, File.ReadAllBytes(“C:\Users\xxxx\xxx.pdf”), ParameterType.RequestBody)
request.AddParameter(“filename”,“xxxxxxx”, ParameterType.RequestBody)
Dim response As IRestResponse = client.Execute(request)
Console.WriteLine(response.Content)

Running time we are getting below errors

Invoke code: No compiled code to run
error BC30456: ‘Timeout’ is not a member of ‘RestSharp.RestClient’. At line 2
error BC30518: Overload resolution failed because no accessible ‘New’ can be called with these arguments:
‘Public Sub New(resource As System.Uri, [method As RestSharp.Method = Method.Get])’: Value of type ‘RestSharp.Method’ cannot be converted to ‘System.Uri’.
‘Public Sub New(resource As String, [method As RestSharp.Method = Method.Get])’: Option Strict On disallows implicit conversions from ‘RestSharp.Method’ to ‘String’. At line 3
error BC30002: Type ‘IRestResponse’ is not defined. At line 8

Note: - without RestSharp we getting error…

Hi @Narotham_B ,

check if Restsharp namespace is imported

Hi @Shikhar_Tandon,

Yes, imported RestSharp namespace imported…

Dim client As RestSharp.RestClient = New RestSharp.RestClient(“https://xxxxxxxx/customers/xxxxx/people/xxxx/fields/xxxxx/binary”)
client.Timeout = 10000
Dim request As RestRequest = New RestRequest(RestSharp.Method.PATCH)
request.AddHeader(“Authorization”,“Bearer xxxxxxxx”)
request.AddHeader(“Content-Length”,“6818”)
request.AddHeader(“Content-Type”,“multipart/form-data”)
request.AddFile(“file”, “C:/Users/xxxxxxx”)
Dim response As IRestResponse = client.Execute(request)
Console.WriteLine(response.Content)
Console.WriteLine(response.StatusCode)

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