Unable to update goals via API

I’m unable to update goals via the python API.

Executing either one of the following:

from hubspot.crm.objects.goals import BatchInputSimplePublicObjectBatchInput

from hubspot.crm.objects.goals import BatchInputSimplePublicObjectBatchInputUpsert

gives the errors respectively:

ImportError: cannot import name 'BatchInputSimplePublicObjectBatchInput' from 'hubspot.crm.objects.goals'

ImportError: cannot import name 'BatchInputSimplePublicObjectBatchInputUpsert' from 'hubspot.crm.objects.goals'

Why is that?

Hi @AAjenifuja

Here is the link to the goals API

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

Hi @GRajput
Thanks for the response, but unfortunately, it doesn’t solve the problem.
I did follow the documentation. From the error, it appears that the functions from the goals module relating to batch updates don’t exist or cannot be used.
I have also recently found this to be the same for the function from the same module for singular goal updates. See the code snippet below.

# import function for singular update to goals
from hubspot.crm.objects.goals import SimplePublicObjectInput

# error received upon execution
ImportError: cannot import name 'SimplePublicObjectInput' from 'hubspot.crm.objects.goals'

I would like to know what the problem is.

Hi @AAjenifuja

import requests
import json

url = "https://api.hubapi.com/crm/v3/objects/goal_targets/goalTargetId"
payload = json.dumps({
 "objectWriteTraceId": "string",
 "properties": {
 "property_date": "1572480000000",
 "property_radio": "option_1",
 "property_number": "17",
 "property_string": "value",
 "property_checkbox": "false",
 "property_dropdown": "choice_b",
 "property_multiple_checkboxes": "chocolate;strawberry"
 }
})
headers = {
 'authorization': 'Bearer YOUR_ACCESS_TOKEN',
 'content-type': 'application/json'
}
response = requests.request("PATCH", url, headers=headers, data=payload)
print(response.text)

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

Hi @GRajput ,
I tried it and got the following error:

{
 "status":"error",
 "message":"The scope needed for this API call isn't available for public use. If you have questions, contact support or post in our developer forum.",
 "correlationId":"xxxxxxxxxxxxxxxxxxx",
 "links":{
 "support":"https://help.hubspot.com/",
 "forum":"https://community.hubspot.com/t5/APIs-Integrations/bd-p/integrations"
 },
 "category":"MISSING_SCOPES"
}

Suggests there’s a restriction on the relevant scope(s) which explains why it doesn’t work. I imagine others are experiencing this too.
Is this being worked on?

Hi @AAjenifuja

please provide this scope to your access token crm.objects.goals.read

Thanks!

Hi @GRajput
My access token already has the scope:

AAjenifuja_0-1737983218497.png

I’d actually have expected the ideal scope to be crm.objects.goals.write

Hi @AAjenifuja

Please connect with the HubSpot support team for further support.

Thanks!