1
HubSpotDocs =  """

The below is Hubspot API documentation showing how to create a contact. 

The endpoint is https://api.hubapi.com/crm/v3/properties/contacts. 

///Example request body to create a new contact
{
  "properties": {
    "email": "[email protected]",
    "firstname": "Jane",
    "lastname": "Doe",
    "phone": "(555) 555-5555",
    "company": "HubSpot",
    "website": "hubspot.com",
    "lifecyclestage": "marketingqualifiedlead"
  }
}
 """

key="KEY"

# Set the headers
headers = {
    'Authorization': f'Bearer {key}',
    'Content-Type': 'application/json'
}


llm = ChatOpenAI(temperature=0, model= 'gpt-3.5-turbo-1106', openai_api_key="KEY")

Test = APIChain.from_llm_and_api_docs(llm, HubSpotDocs,limit_to_domains=None, verbose=True)

Test.run("Create a new entry named Sara")

I am trying to create an agent to connect to the Hubspot API and then take certain actions (e.g. creating a contact). The above code block is the instructions for the LLM. When I run the code above I get the error below:

'The API call to create a new contact named Sara returned an error message stating that authentication credentials were not found. The API supports OAuth 2.0 authentication, and more details can be found at the provided link.'

However, when I use the same endpoint + authorisation token in Postman it works. Why is this?

I guess I am formatting the authorisation wrong or something but I am relatively new to this so would appreciate help.

1 Answer 1

0

You can check below things. 1.Ensure that the API key ("KEY") is valid and has the necessary permissions. 2.Confirm that the API key is not being modified or truncated during the authorization header setup. 3.Verify that there are no extra spaces or characters in the authorization header.

Sign up to request clarification or add additional context in comments.

1 Comment

I have simplified it to be as follows where KEY is hard coded in my script (obviously removed here or security reasons). The below is a direct copy and paste from my script. headers = { 'Authorization': 'Bearer KEY' } I have checked steps 1-3 of your suggestion but still facing the same error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.