I’m trying to simply create a new record using the REST Api. I’m a bit confused on why this is error out with code 400. I was wondering if someone could shed some light on this…
Also, in case of direct calls to a REST API its considered best practice to first create a record using the basic attributes (non-relational), once the create operation is successful the response object of the post will give you a json containing the newly created object’s id.
Then a second patch or put (depends on the fields and situation) should be made to update relationships.
To summarize:
post to create entity
Retrieve newly created record id
update (put/patch) to detail endpoint ex: entity/<entity_id>, with relationship dictionary
Profit!
Please also be aware that the Shotgun REST API usually returns a json with attributes and relationships keys.
For ex, a Task dict might look like (I am just writing the below from memory):
I was struggling to find the response text. I just now saw it buried based on your comment. That helped resolve the ticket. You need a paypal link so i can thank you for your contributions.
@Sreenathan_Nair how does one limit my result of Notes im collecting from shotgun though? I tried setting the limit param but that doesn’t appear to have any affect.
No problem @JokerMartini, happy to help. I was also at one point in time trying to learn this “REST stuff” and can understand how overwhelming it can get. I will mention though that it is very bad practice to share any private information even for a testing site. I understand that you must be constrained for time, but I believe moving forward you should just be able to paste the error object with the sensitive information redacted and that should be enough to help anyone debug the issue with you.
Where size is max number of records and number is the page number. This type of pagination is known as LimitOffsetPagination where the calculation is done after records are fetched.
So if you had 600 notes for example, you could run the query above to get 24 pages i.e 600 / 25 at which point you can increment the number from 1 till 24. Also note that there is a summarize option that one can make use to get the record count.
Please check this link for details about summarizing. I would suggest using summarize rather than querying the entire database to get back a record count.
I’ve been a Pipeline TD most of my career Though for the past few years I’ve ventured into more web services/front-end javascript type projects as well.
Looks to me like you are trying to build something along the lines of a frontend as well. If I could offer some unsolicited advice… I would drill-down and understand various specs for each of your components, there are many specifications out there:
Please do bear in mind though that these are just some guidelines that can be followed (Like PEP8). Once you read and understand the ideologies of these specs, then a lot of the response JSON, API urls, Pagination strategies etc begin to make sense since most globally used REST APIs would adopt and follow some spec or the other.
Also, writing straight html with ajax calls might prove cumbersome for you in the long run. You should really look into ReactJS or Angular to use as the core UI framework for your project, just in case it decides to grow in size as projects tend to do,
I’m no expert on REST or JS or anything like that, just sharing some viewpoints I always keep in mind when starting on a new project.
Good luck to you and do feel free to reach out anytime.
Hi all! Just a heads up that I modified the original post to remove the password and client secret information. Please be mindful about sharing private authentication tokens (and other private data) on this public forum. Thanks!