How do I submit an answer to a quiz by API? I believe can be done via https://canvas.instructure.com/doc/api/quiz_submissions.html - POST /api/v1/courses/:course_id/quizzes/:quiz_id/submissions, but how to I actually provide the answer to that request? There's no parameter in it which looks like it's what I'm looking for. Or maybe I have to use another end point?
The API endpoint you need is this one.
You will need to create an answer json object depending on the "question type" of the question you're trying to answer (see this appendix)
Related
This question already has answers here:
Which REST operation (GET, PUT, or POST) for validating information?
(6 answers)
Closed 5 years ago.
I want to implement a REST endpoint which general purpose is to validate complicated entity in JSON format.
So, the first question is which HTTP method should be used? We can't put JSON into body for GET method. POST and PUT are methods that should be used when some changes are done to the DB but validation doesn't make any changes.
And the second question is what resource name can be appropriate for such endpoint?
The main difference between POST and PUT is that PUT is idempotent while POST isn't.
So, the question is, if you run the same validation request twice, would you expect a different result? I guess no, so PUT probably is the best choice.
I you want to be effectively RESTful, one of the constraint is that an endpoint should target the resource you want to deal with, the HTTP method indicating what you want to do with it. So in your case, I would personally opt for:
PUT /api/v42/validation
As #RomanVottner proposed, you could also tackle this need by considering each request as a "new validation report generation", in which case POST would be more appropriate:
POST /api/v42/validations
Anyway, you're facing one of these edge cases where REST needs to be a bit tweaked, as this need is outside of the CRUD world.
My general rule is.. when you need a full JSON body, go with POST.
Have a post method like /validateJSON or something, GET would not work, PUT doesn't make sense, so go ahead with POST.
Refer to : Which REST operation (GET, PUT, or POST) for validating information?
Cheers.
The question is about JSON API specification and how properly do a request
(I'm using ruby on rails and the json api resources gem but that's a general question anyway, I know how to implement it, I just want to follow the rules of JSON API at: http://jsonapi.org/format/)
Situation 1:
I want to get all shelves
I want to include all books that are on those shelves
The get I'm supposed to use in this case is:
www.library.com/shelves?include=books
Situation 2:
I want to get all books but only books that are marked as unread
The get I'm supposed to use is:
www.library.com/books?filter[unread]=true
What would be correct way of designing request for all shelves with included unread books?
Can't figure this one out
www.library.com/shelves?include=books&filter[books.unread]=true ?
www.library.com/shelves?include=unread_books ? <- would have to specify another resource, books that are unread
www.library.com/shelves?filter[books.unread]=true ?
What's the most correct way of doing this?
EDIT
After speaking with my tech lead and a few other programmers, the first options is favoured the most in such cases
I would bet on the first one:
www.library.com/shelves?include=books&filter[books.unread]=true
JSON API currently does not support filtering includes, but this doesn't mean you have to be strict on the definition (check https://github.com/cerebris/jsonapi-resources/issues/314)
I would go with the same approach as brian:
www.library.com/shelves?include=books&filter[books.unread]=true
I just wanted to give some more background to the answer.
I am trying to use the plivo.com api with Filemaker to send SMS with my database.
I am using "insert from URL" to POST to the api, like below:
(ACCOUNTID, FROMNUMBER, and TONUMBER has been switched out)
httpspost://api.plivo.com/v1/Account/ACCOUNTID/Message/{"src":"FROMNUMBER", "dst":"TONUMBER", "text":"Testing text"}
The plivo site said something about using JSON for receiving, I had tested with other Filemaker solutions (FmSms) and confirm the functionality is working, so it has to be my post query is in the wrong format.
Would be great if someone of experience can give me some pointer in solving this issue.
Linkage to Plivo's documentation regarding messaging
Thanks in advance
Sunny
This will not work with FileMaker alone. The webservice accepts content-type application/json, FileMaker can send x-www-form-urlencoded only.
It may be possible to use a web viewer with some javascript to handle the request and return data back to FileMaker. See the blog post here: http://www.soliantconsulting.com/blog/2014/11/filemaker-and-javascript-ajax-post
Also, the free base elements plugin will allow you to set custom headers and should also work.
I'm looking at the Reddit API and I'm not finding any information on how to pull subcomment JSON.
I want to get a comment and all of its children.
http://www.reddit.com/r/subreddit/comments/commentid/anytext.json will get any particular post posted to Reddit (if you put in the subreddit and the id of any particular article), however using this same method to try to get a comment won't work.
Is there anyway to get this data? I'm doing this in Javascript, but this is an endpoint issue above all else, so that doesn't really matter.
Add .json to the comment permalink, eg https://www.reddit.com/r/test/comments/3azr6z/doge/cshhtsi.json .
I am new to wso2 API Manager, trying to set it up expose my plain HTTP POST back end calls as a REST API. I am sure this is not a new pattern that I am trying to achieve here. The requirement is to convert the JSON data coming in (has array structures) into the HTTP URL query string parameters.
After some research through the documentation and other posts on this forum, decided to go with the script mediator that would parse the JSON data and convert it to a string that can be appended to the endpoint URL. Some how I am not able to achieve this.
I have followed the following post that seems to be very straight forward. As the original poster suggested, I am also not able to use getPayloadJSON() method. Even have trouble using the work around suggested there due to JSON.parse() not working.
Link
Also, this approach of editing the service bus configuration from source view does not sound like the correct option. Is there another elegant solution to achieve this? Thanks for the help in advance.
I was able to get both methods working by using an external script instead of the inline java script. Thanks