OData Post to Create a Taxon

Posted by llivezey@axcess-financial.com on 29-Jan-2020 19:34

I am trying to create a new taxon in Postman, and I'm wondering if this endpoint is actually to create a new entity under that taxon.

So what i'm trying to create is:

Ohio -> Cincinnati

Where I have the states and i'm trying to write a program to add cities.

The url:

The body:

{
"Title": "Cincinnati",
"Description": "Description",
"UrlName": "/cincinnati",
"Name": "Cincinnati",
"TaxonomyId": "ad800504-71a8-4669-b4f0-b58853786336",
"ParentId": "48901807-2140-46a0-bfb5-5c2e5ffc27ba"
}

Response:

{
    "error": {
        "code": "Unknown",
        "message": "TaxonomyId does not exist"
    }
}
I'm wondering why the documentation is asking for a TaxonomyId if I'm trying to create one.  I also tried it without that:
{
    "error": {
        "code": "Unknown",
        "message": "Taxonomy Id is required"
    }
}

All Replies

Posted by jread on 31-Jan-2020 17:42

Is Ohio created under Categories or is it part of a custom Classification?

TaxonomyId is tied to Classifications, you can retrieve them from this endpoint /api/default/taxonomies.  So if Ohio is created under Categories use the idea for that taxon, if you created a "custom" classification use the id from the custom classification, i.e. States.

ParentId would be the Id of the Ohio taxon when creating cincinnati and can be retrieved from

Use POST /api/default/hierarchy-taxa  to create the Cincinnati endpoint

You do not need to include the / in the UrlName as it will result in an error.

Posted by llivezey@axcess-financial.com on 31-Jan-2020 19:55

Thanks for your reply.  I think I figured it out.  I am trying to build a taxonomy (hierarchical), State -> City.  And I just realized that the TaxonomyId is the ID for entire hierarchy.  

So this query pulls ALL states and ALL cities:

{{baseurl}}/api/default/hierarchy-taxa?$filter=TaxonomyId eq a0184709-103d-4a52-aaf4-0f724ca8f6da

This gets a single state by name (Alabama):

{{baseurl}}/api/default/hierarchy-taxa?$filter=Name eq 'Alabama'

This gets the cities in Alabama (which I got from the last query):

{{baseurl}}/api/default/hierarchy-taxa?$filter=ParentId eq 48901807-2140-46a0-bfb5-5c2e5ffc27ba

So once I derived the ID for Ohio in the same way, here is the POST to add Cincinnati:

{

 "Title": "Cincinnati",

 "Name": "Cincinnati",

 "UrlName": "Cincinnati",

 "TaxonomyId": "a0184709-103d-4a52-aaf4-0f724ca8f6da",

 "ParentId": "34cab190-5dd1-41db-ba71-e4e35fd557e8"

}

And that worked!  So I hope this may help someone else.  Thanks "jread"...

This thread is closed