Using Postman with HubSpot Just Got Easier!

Dennis Edson from HubSpot walks through setting up Postman with the CRM Contacts API, including forking the public collection, configuring authentication with a private-app token, and running GET and POST requests. He shows how to fix common scope errors and creates a test contact named Henry Cluckers.
Questions this video answers
Dennis Edson (Developer Advocate at HubSpot).
Hannah Seligson.
Henry Cluckers.
firstname, lastname, email (property names, not labels).
PA Token (set as a global variable).
Chapters
Hello folks, Dennis Edson here, developer advocate at HubSpot. And behind me you can see a new blog post about HubSpot and Postman that my friend and colleague Hannah Seligson has published. She's worked very hard on this and I'm going to go through what Postman is, what the new features we've added and how you can get started. Stick around. Okay, what is Postman? If you have not had a chance to read this article, I will make sure to put a link down in the description below. Hand does a great job of detailing the entire thing, but in short, Postman is going to allow you to build, test and share APIs. We HubSpot use the sharing aspect of it in our documentation. If you go over to the docs, you'll see here that I have the contact object pulled up and you have an option over here says run in Postman, which will allow you to do in the web or download it to your local configuration. This is the way we have done it historically and this has not been updated yet. So what I want to do is just say it's here, keep an eye on it and and this will be updated in the future. Right here we are in postman.com HubSpot blah blah blah blah. I'll definitely have a link to this as obviously down in the description below and it should bring you to something like this. I am signed in with an account and it is a free account. You can use free for this for all purposes. That should be fine. And we want to go down here. This is APIs. As I said, we're working with the contacts. So I am going to find CRM contacts. Click on that and I should be able to right click on this Contacts API collection. Click that, create a fork. Watching this, you'll see that I can name it whatever I want. I'll leave like that because why not put it in my workspace? If I had multiple workspaces, it would show up. I can just choose whichever workspace I want to be in. And this is the important part. Watch the original collection. Watch. What this is going to do is anytime that we at HubSpot make an update, you know, we change it, we delete, we create a new API or Endpoint or just how we work with things. We will merge it here and you will be able to pull down the new definition or whatever changes might be. So let's go ahead and force that collection and now I'll be able to move over to Postman and start working with this. If I Go down here. Workspace, my workspace and collections. You can see now that we have this port forked and there it is, you can see dad Hudson's fork, blah, blah, blah, blah. And we will be able to work from there to make some requests. We're going to list of the contacts on our account. Okay, cool. Here you will see a get request which basically we're asking for information from HubSpot. This thing in your curly braces is called a variable, which is the base URL for the API call. So you'll see here HTTPs API.hubapi.com is the base. You can copy it if you want. This is a global variable, so you can. It's going to be able to use any of these actually. I think it's. Sorry, it's probably scoped specifically to the collection. But you know, let's click on that. I could, yeah, scope to the collection. Then beyond that you'll see we're going actually to the actual endpoint and here you'll see a bunch of query parameters with this weird string thing in it. You'll see down here we can edit these query parameters. So I do just make this simple. We're going to just remove a whole bunch of these. I want leave one property, one on there and get rid of all these other ones. Okay, so we have one property. I'm going to. When we make this call, I want to ask for first name to definitely be returned. You can do this with any property that you have that is associated with the contact record. Just make sure that is the the name, not the label. A label oftentimes will have a space in it. Names will never have a space. All right, so we have first name. We have a get request and we are going to send this request and we have an error. We are not authenticated. This is one of the reasons why you want to be able to test in Postman. These are things, these are common things people run into and we see that we can fix it real quickly. There are two ways to authenticate with HubSpot that you'll be able to use. You can use OAuth or you can use a private app which uses a bearer token. OAuth is a little more complicated, not terribly complicated. And you can definitely do it in Postman. I'll make sure to link to some resources on how to do that. The bearer token with a private app is pretty straightforward. So we'll do that in this demo here. So I'm going to authorization and you'll see the type here we're going to change that to a bearer token. This does not exist anymore, so we'll remove that. And we need to get a token from our account. So let's move back on over to A account and I am in this one and I'm going to go to Settings Integrations, private apps, and I'm going to create a new one specific to this one. We're going to call it Postman. All right, so we have that. I don't really care about the logo, I don't really care about the description. We're going to go into scopes. Scopes are what allow you to work with the various APIs. So going here, we are working with the contacts and I'm going to go into CRM and there is the read write for the contacts and I'm actually going to do. I want to remove the read real quickly just to show you another error that's going to happen if you don't have the right scopes. So I'm going to create this app. Continue. This brings me to the bearer token, the key. So click on that. If you ever expose this, please go ahead and rotate it. It's pretty simple to rotate. You go to the auth section and there's a rotate option here, here. All right, going back over to Postman, I'm going to put that token in and honestly, I'll forget this later on. So what we're going to do is make a variable out of this. I want to highlight the entire thing, which allows me to set it as a variable. We don't have anything. We're going to set a new variable and I'm going to call it PA Token and that's the value. And we're going to scope this scope. As I said, this one here was scoped to this collection. I want to do a global so I can use this elsewhere outside this collection. And I'm going to set that variable. And now you'll see in curly braces again, we had the PA token and I'll hit send and we are going to get another error. This app hasn't been granted all the required scopes and it needs one of these two here, which is Object Contacts read or Schemas Contacts read. So let's go ahead and add. This is again, testing with Postman allows you to, you know, deal with all these errors before you build your app out. All right, let's go back to here and I'm going to go to the auth and I'm going to edit the app. Go to scopes go to CRM and I'm going to add that. Read scope, commit changes. Commit scope changes. Really simple. With a private app. It just. This just works. If you were to do this with a public app, you actually need to have the user re authenticate because you can't just randomly add new scopes without end user's permission. Okay, going back here and if we hit send again we should get yes the results. And you can see here is listed into the objects. You can, you know, go and do this so you can see other ones. And you'll see I have the first name property which I did ask for in my parameters. So let's say just, just for fun, let's add. Instead let's do. Here I'll add another property and call it last name as well. Send. And now we have last name. Cool. Let's actually do a. Let's create a contact. Why not? So we're gonna go to post create and see we saw that base URL. If we go to authorization. Let's go ahead and move this over to that bearer token which automatically just ports over my token. Cool. Headers. We don't have to worry about right now. We're gonna go to the body and this might look a little daunting. Don't worry about it. We're just not gonna do any associations right now. What we're going is take associations all the way down to properties out. So get rid of that. And nice thing about Postman is you can use this little beautify. So let's pretend like tab. Tap tab. This is all messed up, right? Hit beautify. Boom. Makes it pretty. And we are going to change this to first name. And this one's going to be last name and this one's going to be email. All right, first name is going to be Henry and this one's going to be Cluckers. And this one's going to be H. CluckerSlucks Inc. Dot com. All right, and let's hit send. So we're making a post request. We're sending data to HubSpot. We're creating a new contact with this. All right, hit send. And there we go. You will see. Now we have an email. We have a create date. All that good stuff has been added. If we went back into our contacts. Contacts here. And we can see that we have. What did I call it again? I forget what. Henry. Right, Henry. Henry Cluckers. There it is. And all that information is there. So that is how you are going to use Postman. If you have any more questions about this, please feel free to ask in the comments below. Again, I will link to Hannah's really well thought out blog post and I want to thank her again for working so hard on making this a reality. Have yourselves a great day. Bye Bye.










