📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

Part 8 - Azure AI Foundry - Using POSTMAN against Deployment

LinoTV4:54

Transcription

Hello again, this is Leno Tadros.

I have one more thing to add to the previous video. I did actually use the deployment for the prom flow, and I ended up testing it and consuming it in Python. However, I received a question in the forum asking if I can do this with curl or Postman instead, because some people are encountering 403 and 401 authorization problems or bad errors.

So, let me go ahead and demonstrate how to do this in Postman as well, to show you the trick for making this happen.

The trick here, folks, is that after the deployment takes place, if you go to Models and Endpoints, you will notice at the bottom that I have a brand new endpoint. If you click on this GET endpoint, it will provide you with all the information you need.

First of all, the endpoint URI is right there—that's important. And of course, the API key that I will need in whatever application, in our case, will be Postman.

So, I'm going to copy this endpoint to the clipboard. Let me keep this on. I'm going to bring in Postman here and show you what's going on with this as well.

All right, I created a brand new workspace called Azure AI Foundry. It doesn't have any collections or requests yet, so I'm going to create one.

Let's go ahead and do that. We will say "New" and create a collection. We can call this one "Vision" or whatever we want. Then, I'm going to state my first request in Postman, and this one will say "Get Receipt Info" or again, you can call it whatever you want.

This one, we know, has to be a POST request because we're going to send the entire base64 image to it. I'm going to get the endpoint that I just copied and pasted from my deployment.

There it is; that is the one that ends with the "SL" score. That's an important piece as well. There are a lot of different ways to enter the API key, by the way. You can do it in the params, or you can do it from authorization by going to the API key. Notice there's one in here called the API key. You can also do it based on the bearer token.

However, I prefer to keep them all together under the header. So, if I click on "Header," I'm going to come in here and say "Authorization." The value of it—I’m going to go back to my endpoint and copy my key from right there.

Now, I don't need this anymore; I can close it and let's get back to Postman. All righty, and I'm going to be able to paste it right there.

Well, that's not 100% correct. I know there is some documentation out there that actually says that the authorization is this API key, or sometimes they say that the key itself needs to be called "ap-key."

Well, it is authorization, but you need to go right before that key and put the word "Bearer" with a capital "B" and a space right after it. Otherwise, this will not work, unfortunately.

Okay, so I'm going to save all the stuff for right now. I'm done with my header. Now I need to concentrate on the body.

In the body, we'll go to "Raw" and I’ll enter my JSON myself. So, we'll come in here and say I'm going to create something called "photo." It has to be called "photo" because that's what my prom flow had.

Inside of this double quote, let me bring up the dev tools one more time. I'm going to copy the base64 of my receipt. We'll say "Copy" this guy, and I'm going to paste it right inside of these double quotes.

All right, now let's go and say "Save."

It's the moment of truth. I think I'm ready. So, the headers in here—make sure that the content type is "application/json." That's another mistake a lot of people were complaining about; it’s going to text and it doesn’t work.

The authorization has to be "Bearer" space and your API key, and in the body, we will have to have a JSON object that contains the name of the element that you've created in the prom flow and the base64 in here.

All right, let's go ahead and give it a shot and see if this will work. Click on "Send." Drumroll, please!

If we've done everything correctly, Postman should be able to send this, and yes, it did work! The date on the receipt is November 22, and notice it's 5139, and the guest dining is 2. Everything in this one is 100% correct as well, which is great.

Hopefully, that was useful to you to show you a little bit of tricks on how to get that working. It will be pretty much the same thing if you use curl. Just remember that you have to pass the application JSON, and the API key has to be a bearer before it.

So, it's the same thing like Postman. If you're using Fiddler, it's the same way, or any other tool that will send a POST request to be able to get this response back.

Hopefully, this was useful. I hope you can like this and subscribe to my channel, and I'll see you again in a future video. Thank you so much!