HTTP Request Error 500

Hi there,

The API that i’m trying to workout works well in Postman - see image attached (postman-api-success.png) however when i replicate the settings into UiPath Http Request, i kept getting error 500 - see image attached (UiPath-http-request-failed.png)

Any help would be much appreciated.
Thanks.

Hi,@jordan.chang
If possible, I hope to provide development documentation for this API, and I can tell you that I haven’t seen any valuable information so far.
Regards.

Hi @jordan.chang, Welcome to UiPath Community.

HTTP request activity body format may not match to API accept format. You can write a xml or JSON body format(not from the parameters UI) and try like that.

Cheers :slightly_smiling_face:

Hi @jordan.chang,

Internal Error 500

The server encountered an unexpected condition which prevented it from fulfilling the request .

Regards,
Arivu

Hello Jordan,
In these videos you will see how I attached files in different system like ServiceNow and Jira:

Maybe this will help you to understand what you miss on your procedure.
Thanks,
Cristian Negulescu

Hi Guys,

Thanks for your replies, i’ve noticed that there is a type for the file that i’m trying to upload. Without putting the file type i get the same exact error message in UiPath which i believe is the reason for that fail upload. Below is a snippet of my curl command:

My question is, Is there a way to put the file type into the HTTP Request?

Unfortunately there isn’t at the moment, but we are looking into providing support for that in future releases. I will try to post an update here when that happens.

Hi @Tudor_Sandu,

Thanks for your reply. Yup, please do update them in this post as it will be useful for me or anyone else who will be needing it in the future.

As an alternative after hard trial and error as well as some help from @Vishal_K’s post, i finally found a solution to upload XLSX into the system via API.

Please follow exactly the pre-requisites that needed for this as per this post Unable to Http Request POST API With Attachment . Based on the code that @Vishal_K provided i’ve made a minor modification by including the content-type into the attachment. Please see below for the code:

Dim client As HttpClient = New HttpClient()
client.BaseAddress = New Uri(“https://api.example.com”)
client.DefaultRequestHeaders.Accept.Clear()
client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue(“application/json”))
client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue(“Basic”, “<hash code>”)
Dim request As MultipartFormDataContent = New MultipartFormDataContent()
Dim sc As StreamContent = New StreamContent(File.OpenRead(“C:\UiPath\Development\data\example.xlsx”))
request.Add(sc,“file”,(New FileInfo(“C:\UiPath\Development\data\example.xlsx”).Name))
sc.Headers.ContentType = New MediaTypeHeaderValue(“application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”)
Dim response As HttpResponseMessage = client.PostAsync(“”, request).Result
If response.IsSuccessStatusCode Then
Dim responseContent As HttpContent = response.Content
Dim responseString As String = responseContent.ReadAsStringAsync.Result
Console.WriteLine(responseString)
Else
Console.WriteLine("failed: " + response.Content.ReadAsStringAsync.Result)
End If

:slight_smile: