# Problem in API Integration -External Contact API and problem with Scopes

**URL:** <https://community.hubspot.com/t/problem-in-api-integration-external-contact-api-and-problem-with-scopes/37166>\
**Category:** APIs & Integrations\
**Tags:** free\
**Created:** [May 12, 2021, 5:42am UTC](https://community.hubspot.com/t/problem-in-api-integration-external-contact-api-and-problem-with-scopes/37166 "2021-05-12T05:42:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![harjap\_x](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/harjap_x/32/97852_2.png) [@harjap\_x](https://community.hubspot.com/u/harjap_x)\
**Post date:** [May 12, 2021, 5:42am UTC](https://community.hubspot.com/t/problem-in-api-integration-external-contact-api-and-problem-with-scopes/37166/1 "2021-05-12T05:42:41Z")

</div>

I tried API Integration with Contacts API and tried testing it through postman.

const hubspot = require(‘@hubspot/api-client’)

const express = require(‘express’)

const app = express()

app.use(express.json())

const fs = require(‘fs’)

app.post(‘/add’, async function (req, res) {

try {

const contactObj = {

properties: {

firstname: "AnyName ",

lastname: “AnyName2”,

},

}

const companyObj = {

properties: {

domain: ‘Any1’,

name: “Any2”,

},

}

const hubspotClient = new hubspot.Client({ apiKey: ‘88ba97a7-67bb-42b6-a888-2effa2b-----’ })

const createContactResponse = await hubspotClient.crm.contacts.basicApi.create(contactObj)

const createCompanyResponse = await hubspotClient.crm.companies.basicApi.create(companyObj)

const result = await hubspotClient.crm.companies.associationsApi.create(

createCompanyResponse.body.id,

‘contacts’,

createContactResponse.body.id,

‘company\_to\_contact’

)

res.send(result)

} catch (err) {

res.send({ message: ‘error’, err: err })

}

})

But, when I test it in Postman I get an error for scopes:

 ![harjap_x_0-1620797956090.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/5/15cda429881e481196c494426b98f531a3641d32.png)

I have already added these scopes in my App Auth as well.

 ![harjap_x_1-1620798034961.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/9/2/920258354a147924c53be37b8212d892479f4c8f.png)

But I’m still getting the same error. Can anyone help me please I’m new to this…?

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [May 12, 2021, 4:52pm UTC](https://community.hubspot.com/t/problem-in-api-integration-external-contact-api-and-problem-with-scopes/37166/2 "2021-05-12T16:52:08Z")

</div>

@PCarlson , @shizaki, @prosa could any of you lend [@harjap\_x](https://community.hubspot.com/t5/user/viewprofilepage/user-id/189587) a hand?

---

<div class="post-metadata">

**Author:** ![PCarlson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pcarlson/32/35493_2.png) [@PCarlson](https://community.hubspot.com/u/PCarlson)\
**Post date:** [May 13, 2021, 1:10am UTC](https://community.hubspot.com/t/problem-in-api-integration-external-contact-api-and-problem-with-scopes/37166/3 "2021-05-13T01:10:41Z")

</div>

Just guessing, but the message seems to indicate the problem is that the app has not been granted permission for requested scopes, so I suspect it is related to setup rather than your specific code.

I was able to create contact, company and association using only the Contacts scope. So I would start by paring down the scopes in your app to only what you need, i.e. start with only the Contacts scope. Then you can add more scopes as you add code.

Good luck.

Phil
