Building a custom API from scratch with custom objects

Have more questions? Submit a request


  • Azhar
    Comment actions Permalink

    While posting the data using API request to create a doggo record, we are getting 404 error. We have checked all the configurations and files and it looks fine to us as per the article above.

    Getting below error :

    <title>Error: 404 Not Found</title>
    <style type="text/css">
    html {background-color: #eee; font-family: sans-serif;}
    body {background-color: #fff; border: 1px solid #ddd;
    padding: 15px; margin: 15px;}
    pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
    <h1>Error: 404 Not Found</h1>
    <p>Sorry, the requested URL
    caused an error:
    <pre>Not found: &#039;/api/doggos&#039;</pre>

  • Charles Nadeau
    Comment actions Permalink

    Hi Azhar,

    404 means the server couldn't find the file, which in Bottle terms means it couldn't find a route to the endpoint. Can you check the endpoint's route in your file. It should be:

    @route('/api/doggos', method='POST')

  • Azhar
    Comment actions Permalink

    Hi Charles,

    Yes, the endpoint route in my is exactly same as what you mentioned but I am receiving the 404 error every time I am running the python file normally and hitting the POST or GET request either form POSTMAN or CURL. 

    Whenever I am executing the file in debug mode using -m pdb then for the first time when the code reaches on fetching json request after establishing connection getting failed  but upon several attempt  it is able to post successfully and I am receiving the response  i.e. only when debug mode is on and connection getting establish upon repeating after failing once, we are receiving the response. I am exactly clueless of this weird situation now.


    Normal Scenrio :


    Debug Mode Scenario  (after repetitive attempt):


    We want flawless consistent response. Need help in this regards.

  • Charles Nadeau
    Comment actions Permalink

    Strange. I retested the app this morning and it still works for me. I notice in your Postman screenshots that you included the "-v" verbose flag in the endpoint URL. The field is a web address, not a curl statement. The extra "-v" will return a 404 error. You didn't include the -v flag in the example that worked.

  • Azhar
    Comment actions Permalink

    That -v  might be due to the copy-paste. But it didn't worked for me without that flag too in normal scenario. Please find the screen shot below :


    Let me know if I can attach my files somewhere which I am running to achieve the result,so that you can simply run my file and can detect if by mistake I have been doing something incorrect in the file.


  • Suman Saha
    Comment actions Permalink

    Hi Charles,

    I have created this api and is working fine. I'm able to access data with api calls for e.g.


    Now I need to call the same API from a custom app, that I have built in Zendesk Support and display the data there for the same user (with id 407611529753).

    How do I call the API?

    I tried the below but it did not work. 

    function requestUserInfo(client, id) {
    var settings = {
    //url: '/api/v2/users/' + id + '.json',
    url: 'api/sunshine/objects/records/zen:user:' + id + '/related/owner_has_many_doggos',
    dataType: 'json',

    Can you pls help me or direct me to some documentation where I can find some help.

    Also just a thought is it something to do with the datatype that is getting returned?

    the same urlis working in Postman:



  • Charles Nadeau
    Comment actions Permalink

    Hi Suman,

    I noticed a slash is missing at the beginning of the url property:

    url: 'api/sunshine/objects/records/zen:user:' + id + '/related/owner_has_many_doggos',

    Maybe that's the culprit? Can you try:

    url: '/api/sunshine/objects/records/zen:user:' + id + '/related/owner_has_many_doggos',
  • Banhi Kumar Ratha
    Comment actions Permalink

    Hi Charles,

    I called sunshine api from Support sidebar its working fine but when I tried to call from Zendesk Sell sidebar , I am getting error.

    My javascript code:

    var issueInfoRequest = {
                 url: "/api/sunshine/objects/records?type=[type]",
                 dataType: 'json',
                 type: 'GET'   };

    client.request(issueInfoRequest).then(function(response) {

    Can you please help on this.

    Note: From support sidebar its working




  • Bryan - Community Manager
    Comment actions Permalink

    Hello Banhi Kumar Ratha. It's not clearly documented but but the ZAFClient request method is not fully supported in Sell apps to call either Sunshine or Zendesk Apps proxy (ZAP) endpoints.

    You can, however, directly access Sunshine APIs by including an Authorization header with a Bearer token using something like:

        var settings = {
    url: '',
    type: 'GET',
    dataType: 'json',
    headers: {
    "Authorization":"Bearer b103260d80b103260d80b103260d80b103260d80b103260d80b103260d80"

    function(data) {
    console.log("success:", data);
    function(response) {
    console.log("error:", data);

    Note, because it's a cross-origin call, the call has to use an OAuth Bearer access token — not a "Basic" username/password value.

    For other caveats and limitations, see Known app limitations. This article may also be interesting to have as a reference for other work — it's more Zendesk Support specific, but may still be helpful: How Apps framework client.request works.

    The above workaround will not be ideal for everyone. This limitation is known to the product team but I can't say when (or technically even if) this will be addressed. I'm hoping this at least sets expectations and gets you to your next steps!

  • Jon Simone
    Comment actions Permalink

    Followed article and it seems like it may need to be updated. I am receiving the following error when running the python3 command for the first time:


    Traceback (most recent call last):

      File "/Users/jonsimone/Coding/doggogo/", line 40, in <module>

        response = sunshine.create_object_type(key, schema)

    NameError: name 'sunshine' is not defined

    I checked on the github files and they do not name the first file but instead. I am new to this so I am wondering if this makes a difference. Any help is appreciated. 

    Also wondering how to authorize using a token instead of user name and password in /

    Edit: Renaming to seemed to help but needs to import sunshine and not zendesk. 

    Also for credentials just convert username\token: to base64 and add it like this: 

    credentials = '_base64token_'


    Having done all of this I am now encountering a new problem when running 

    Traceback (most recent call last):

      File "/Users/jonsimone/Coding/doggogo/", line 42, in <module>

        response = sunshine.create_object_type(key, schema)

      File "/Users/jonsimone/Coding/doggogo/", line 12, in create_object_type

        response =, json=data, auth=credentials, headers=headers)

      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/", line 119, in post

        return request('post', url, data=data, json=json, **kwargs)

      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/", line 61, in request

        return session.request(method=method, url=url, **kwargs)

      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/", line 528, in request

        prep = self.prepare_request(req)

      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/", line 456, in prepare_request


      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/", line 320, in prepare

        self.prepare_auth(auth, url)

      File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/", line 551, in prepare_auth

        r = auth(self)

    TypeError: 'str' object is not callable

    Any ideas?


Please sign in to leave a comment.

Powered by Zendesk