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.