Help with POST call to external API using Network API on UI Builder

Hello,

I am trying to build an API call to an external system but cannot make it work.

The intended use case is that a user will upload a picture of a receipt, and it will then be sent to an OCR scanner application, who will return JSON data extracted from the receipt.

The OCR application is Receipt OCR API » Veryfi

The API docs are only available to account holders, so I will C&P the relevant sections.

I have gone into business logic to build the API service, and the first function I want to add is a POST function that sends an uploaded receipt to the OCR scanner. The function name is Send-receipt.

The API docs instruct me to send the following auth parameters in the header of the request:

I have included these in the the logic for the API service:

The API documents then show the format for the CURL request:

I have used the correct path name, and query fields, but the problem occurs before this stage because I get a 400 error saying NOT AUTHORIZED when I try to invoke the API service in business logic.

The path name and API credentials are correct, so I am stuck with this. I have contacted Veryfi but they need to see the code being submitted with the request, and I can’t find where I can access this.

Am I doing something wrong with my logic? Or, if not, is there somewhere I can get code samples for Veryfi?

Thank you

Hello @Luc_Zentar

I am sure the problem is the way how you set authorization tokens.

image
I think there’s no need - "

Also, you can make a request, copy them as cURL(Network Tab in Dev Tools) and provide it to Veryfi, they definitely know what needs change in your request, and with their answer, I can help you how to do it in UI builder.

Regards, Dima

Thank you @Dima

I have removed the “” from the authorization tokens, and I have also removed the file_name and externalId parameters as they are not necessary for the call.

The API logic now looks like this:

When I try to invoke within business logic I get a new error:

I have also built a button to test in UI Builder, using this logic:

When I invoke this, I get the following in the network tab

Any further help appreciated!

Thanks,
Luc

Could you remove " from file_url on the first screen and try one more time?

@Dima it has the same problem

Hello @Luc_Zentar

I assume the Create Object block with the file_url key should be connected to the body input of the HTTP block. Have you tried this?

Fixed, thank you @vladimir-upirov