creating custom object using private app token

Hi,

Trying to create a custom object:

curl --request POST --url https://api.hubapi.com/crm/v3/objects/campaign --header 'authorization: Bearer ............' --header 'content-type: application/json' --data '{"properties": {"property_string":"campaign_name"}}'

And getting back:

{"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":"82ceaf50-b139-4e58-a7c6-9da301e1bbf7","links":{"support":"https://help.hubspot.com/","forum":"https://community.hubspot.com/t5/APIs-Integrations/bd-p/integrations"},"category":"MISSING_SCOPES"}

Our Private App has all possible Scopes enabled.

Hey, @PBaranov! Thanks for reaching out. Our team just put out this guide — How to Build a Custom Object Using Private Apps

Can you try following the steps by step there and letting me know if you can get the example working as expected, please?

Thank you! — Jaycee

I’ve successfully created a new Schema:

curl --request POST --url https://api.hubapi.com/crm/v3/schemas --header 'authorization: Bearer #################' --header 'content-type: application/json' --data '{
 "labels": {
 "singular": "Campaign",
 "plural": "Campaigns"
 },
 "requiredProperties": [
 "campaign_name",
 "campaign_friend_name"
 ],
 "searchableProperties": [
 "campaign_name",
 "campaign_friend_name"
 ],
 "properties": [
 {
 "name": "campaign_name",
 "label": "campaign Name",
 "isPrimaryDisplayLabel": true,
 "type": "string",
 "fieldType": "text"
 },
 {
 "name": "campaign_friend_name",
 "label": "campaign Friend Name",
 "type": "string",
 "fieldType": "text"
 }
 ],
 "associatedObjects": [
 "CONTACT"
 ],
 "name": "campaign_name",
 "primaryDisplayProperty": "campaign_name",
 "metaType": "PORTAL_SPECIFIC"
}'

But I’m still not able to create a new object:

curl --request POST \
 --url https://api.hubapi.com/crm/v3/objects/campaign \
 --header 'authorization: Bearer #############################' \
 --header 'content-type: application/json' \
 --data '{
 "properties": {
 "campaign_name": "op_campaign_01",
 "campaign_friend_name": "campaign 01 friendly name"
 }
}'

I get back the same 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":"f41082a8-796a-4f1f-8d93-09d11216bfdc","links":{"support":"https://help.hubspot.com/","forum":"https://community.hubspot.com/t5/APIs-Integrations/bd-p/integrations"},"category":"MISSING_SCOPES"}

Hey, @PBaranov. Thank you for clarifying. I am trying to reproduce the issue on my end. Once I get it to throw the same, or a similar, warning, I’ll reach out to my internal resources. — Jaycee

Hey, @PBaranov. Quick request. In your payload can you use objectType and not the custom object label, please?

Here’s what I did:

  • followed this guide to create the custom object schema
    I used only the four scopes used in the article

  • This created the object Boats with the objectType of 2-7913954

  • I used the endpoint — Create
    POST /crm/v3/objects/{objectType}​

  • Which returns the response of HTTP 201

  • My request

    curl --request POST \
     --url https://api.hubapi.com/crm/v3/objects/2-7913954 \
     --header 'authorization: Bearer MY_PRIVATE_APP' \
     --header 'content-type: application/json' \
     --data '{
     "properties": {
     "hin": "002",
     "make": "skidoo",
     "model": "uber ski",
     "year": "2019"
     }
    }'​
    
  • The response

    HTTP 201
    
    {
     "id": "1976776222",
     "properties": {
     "hin": "002",
     "hs_createdate": "2022-07-26T16:47:35.134Z",
     "hs_lastmodifieddate": "2022-07-26T16:47:35.134Z",
     "hs_object_id": "1976776222",
     "make": "skidoo",
     "model": "uber ski",
     "year": "2019"
     },
     "createdAt": "2022-07-26T16:47:35.134Z",
     "updatedAt": "2022-07-26T16:47:35.134Z",
     "archived": false
    }​
    

    One last question — is this happening in an App Test Account created via a Developer Account? Or in a paid production account?

Thank you! — Jaycee

Using “objectType of 2-7913954” worked. Thank you!

It is showing "

Invalid object or event type id: 2-7913954" for me.