Custom objects handbook

Have more questions? Submit a request

34 Comments

  • Mark DiValerio

    Can Custom Objects and Relationships be retrieved via the support app client? i.e. sidebar_client.get("relationships") or sidebar_client.request("/api/custom_resources/resources/{resource_id}/relationships/{relationship_type_key}")??

     

    Thanks,
    Mark DiValerio

    0
  • Bryan Flynn

    Hi Mark. The interface to Custom Objects is only through REST APIs right now. There is a strong interest in having a tighter integration with the Apps framework, however, so keep an eye out in the future for changes such as this.

    0
  • Joseph May

    Hi there Mark-

    As Bryan pointed out, a tighter integration with the apps framework is not available right now. That said, your second example would still work with the Zendesk Apps framework - the only option currently is using client.request().

    Regards,

    Joey

    0
  • Ben Heiligenthal

    Is there a size limit for the data array for a job? I'm trying to bulk import ~4000 custom objects and I'm not sure if this can all be done in one job, or if there is a better way to bulk import custom objects other than via the API.

    0
  • Bryan Flynn

    Hi Ben. The limit is a 1000. It's not documented right now but soon will be.

    0
  • Ben Heiligenthal

    Thanks for the response Bryan. One more question, when inserting relationship records, can this be done with the external_ids of each object? Or does it have to be the ids generated from when created in zendesk?

    0
  • Bryan Flynn

    Hi Ben. It's the Zendesk generated ID of the resource.

    0
  • Ben Heiligenthal

    So there is no way to use the external_id? 

    0
  • Bryan Flynn

    Can you give more details on your use case Ben?

    ID is the attribute that is guaranteed unique across all resource types. If you give more details maybe there's some approach that can get you what you're looking for.

    0
  • Jason Martens

    Hi Ben, it sounds like you want to have external IDs in the source or target of a relationship, is that correct?

    If so, this is not something that you can do currently. The workaround is to create a relationship to an object, then get the external ID from that object. 

    0
  • Ben Heiligenthal

    Jason,

    Yes, using the external_ids in the source and target was my intent. I can do it without using them, it just would have been a nice convenience. Thank you for the response

    0
  • Ben Heiligenthal

    Deleted my previous comment. Figured out the links. Now I just have this question:

    How do I get more objects per page in a GET to get all of my objects of a certain type? What should the url look like?

    0
  • Bryan Flynn

    Is this what you're looking for Ben?

    You can specify up to 1000 records per page using the per_page parameter:

    https://developer.zendesk.com/rest_api/docs/custom-objects-api/resources#parameters

    If listing object records by object type key, you can use the following optional query string parameters:

    Name Type Comment
    per_page string Number of object records per page from 1 to 1000

    Example:

    https://{subdomain}.zendesk.com/api/custom_resources/resources?type=product&per_page=100
    0
  • Matt Owens

    Any way we could get the "next page" in web JSON view to link to the next and previous page? Perhaps also a page with the per_page parameter?

    0
  • Ben Heiligenthal

    Thank you for your help, those suggestions were what I was looking for. Now I have another question:

    When I try to delete all my object records (for testing purposes to test bulk adding them afterwards) I successfully delete all records (~4000) but one. No matter what I try I can not delete this specific record. I get the error 

    Invoke-RestMethod : The remote server returned an error: (412) Precondition Failed.

     

    I'm not sure why this is happening. Any ideas?

    0
  • Bryan Flynn

    Hi Ben. Is it that particular record or just whatever the last record is that can't be deleted? I'm thinking maybe there's a relationship with another object type that's somehow keeping that record from being deleted.

    This may also be an issue that's specific to your instance and what Custom Objects is doing behind the scenes. Please enter a ticket with support@zendesk.com and we can dig into it deeper.

    0
  • Ben Heiligenthal

    Bryan, 

    You were correct, after I deleted relationships I was able to delete all of the Object records. Thank you for all your help

    0
  • Bryan Flynn

    Great to hear! Thanks for sharing Ben.

    0
  • Matt Owens

    Hey all, 

    Wanted to see if there might be any plans to support a look-up by external_id on custom objects? 

    Use Case: We are looking to use Objects as Projects. Each project is assigned an ID internally. As project progresses, people are added and removed. Additionally we update the state of the project as well as attributes through the Lifecycle. 

    Currently we'd have to write back the Zendesk Object ID after creation into our own DB. If we could just perform a look-up on external id it would simplify updating as well as avoiding duplicate object creation. 

    Best, 

    Matt 

    0
  • Jason Littrell

    @Matt Owens: I don't see this documented anywhere, but this works for me:

    GET /api/custom_resources/resources?type={resource_type}&external_id={external_id}

    You have to declare the resource type with the external ID or the call will fail. I think it's set up that way because the custom resources API only enforces unique external IDs per resource type.

    0
  • Matt Owens

    Thank you @Jason!

    This is incredibly helpful, changes some build plans for sure!

    0
  • Josh Keller

    Any hints on if/when custom objects will available via Liquid code in triggers and automations? Because that would be amazing.

    0
  • Justin Fenech

    Is there any need to created a 1:1 relationship between a ticket and a custom object, rather than just define the ticket ID as an attribute in the object itself?

    0
  • Jason Martens

    Hi Justin,

    You could certainly put a ticket ID inside the resource itself. The advantage of this is you can get the resource and ticket ID in one request. The downside is you cannot do queries for "tickets related to a resource" through Custom Objects. 

    0
  • Justin Fenech

    Makes perfect sense, thanks Jason!

    0
  • Jonathan Brown

    Hey,

    For some reason the API schema isn't matching to my schema in sunshine

    Schema from sunshine:

    {
    "data": {
    "key": "customform",
    "schema": {
    "properties": {
    "subject": {
    "type": "string",
    "description": "\tpopulates both the form heading and the ticket subject"
    },
    "subtitle": {
    "type": "string",
    "description": "appears bellow the forms heading"
    },
    "call_to_action_heading": {
    "type": "string",
    "description": "heading line of link box on the article page"
    },
    "call_to_action_link_text": {
    "type": "string",
    "description": "text that links to the form from the article page"
    },
    ...

    But then when calling the api for a record I get :

    {
    "data": {
    "type": "customform",
    "id": "e27affa1-7dcd-11e9-8810-5b90e7267ad9",
    "external_id": null,
    "attributes": {
    "Subject": "problems logging in",
    "subtitle": "test sub",
    "CallToActionHeading": "test cta head",
    "CallToActionLinkText": "test cta text",
    "phone_type": "TAS",
    "info_type": "TAS",
    "info_text": "test test info text"
    },
    "created_at": "2019-05-24T02:44:43.299Z",
    "updated_at": "2019-05-24T02:44:43.000Z"
    }
    }

     

    Notice the random capitalization on Subject, and the camel casing on CallToActionHeading.
    Why is this? how can i resolve this?

    I also get issues creating records if i try to follow the schema from sunshine rather than using capital S and camel case. 

    0
  • Bryan Flynn

    Thank you for reporting this Jonathan -- I'm looking into this and will get back to you. I'll say this is not what is expected but am trying to find out more details.

    0
  • Jonathan Brown

    Thanks for looking into it.
    I created a new object with the same parameters and it worked correctly. 
    I did some trouble shooting where I then edited that record so the attributes were different (using the admin interface not the api) and tried to submit a new record using the old params and it worked.

    So I suspect the editing of a record structure isn't updating the expected schema everywhere correctly.

    0
  • Bryan Flynn

    Hi Jonathan and thank you again for reporting this. It is indeed an issue, relating to the UI of the admin area as you discovered. And to confirm with your experience, going through the API does not surface the problem.

    A fix is being worked on, but in the meantime, use the API. I'll try and post here when the fix is confirmed.

    1
  • Jonathan Brown

    Is there a way for end users who are not signed in to query the sunshine objects?

    From within zendesk guide we want to call the sunshine api and return some objects we've stored there. 
    Ive got "end_users_can_read" set to true but it seems that only applys to signed in end users, we need anyone to be able to make the api request.

    I considered using an authentication token but since the only way to do that is to have that visible in our front end client and there is no way to restrict the token to just access sunshine or something like that, the solution doesn't work either.

    As a work around we've created our own public API that works as a proxy to call zendesk(with hidden auth), but this isn't ideal for us and really seems silly to go from zendesk guide -> our proxy -> zendesk sunshine. 

     

    0

Please sign in to leave a comment.

Powered by Zendesk