Need help in sending API request

Hi all,
I’m facing an issue in sending API call POST request. I’m using Azure form recogniser here, i want to post my PDF to azure custom model using API call then i need to retrieve the output using another GET - API call. The challenge here i’m facing is unable to post my PDF in HTTP request. I’m using HTTP Request Activity to do this.

Can anyone help me how to solve this.

@Learner007

Did you try using the attachments peoperty in the http request?

Cheers

Hi @Anil_G i tried in Attachments. I will check those properties once.

Hi @Anil_G when i paste my file path in " FILE ATTACHMENTS" it is showing an error - Unrecognized Escape Sequence

@Learner007

Did you try this?

the attachment name should be the parameter name that you give for attachment in the api request

For file attachments you need a Ilocalresource which you can get as an output from path exists activity that needs to be passed there

cheers

I didn’t get this what is Parameter name here. i have tried before like “File” & “Source” after that i gave my local file path.

What is the API expecting?

  • form data, multi part…
  • which key for the attachments

In some scenarios the HTTP Activity cannot create requests as needed and we do a custom call setup e.g with RestSharp /HttpClient code

Hi @ppr i have a custom model in azure form recognizer to extract invoice data. First i need to send my local PDF file to Azure - This is my first HTTP request call i need to do.
Header i used – “application/json”

@Learner007

To start with did you try the call in post man ? were you able to successfully send request?

cheers

@Anil_G i did this in cognitive services there i’m using blob storage i want to replace that with Local file path

@Learner007

Agreed so first does the api support attachment or does it support only blob storage files?

If you want to upload from local to blob then check this

Cheers

@Anil_G here i’m trying to eliminate blob storage, using blob storage my code is working fine. Now instead of Blob storage i want to use local storage. I want Send a POST request attaching my local file in HTTP request

How to check this

Hi @Learner007

I would suggest first try to execute the api request using postman and then use the same properties in UiPath request.That way you can see what is the error that you are getting.

And does the api request support attaching files? do you know that? or it required a blob location as input always?

cheers

In Postman i got below error

{
“error”: {
“code”: “InvalidArgument”,
“message”: “Invalid argument.”,
“innererror”: {
“code”: “ParameterMissing”,
“message”: “The parameter urlSource or base64Source is required.”
}
}
}

@Learner007

Perfect that means your api request itself is wrong…please check the official documentation of what api you are using and correct that first

As Per error I see it is expecting a url itself or a base64 encoded i believe or the parameter for passing the file is different or the api request itself is different which you can get details from the api documentation iteself

cheers

@Learner007

To convert to base64 please look at this

cheers

I will check this once

1 Like

where can i use this base64 input in HTTP request Activity

@Learner007

I place of the url string what you used to pass for blob…pass the base64 and try

You can check the video in the link I gave in previous comment it has details on how it is being used

cheers