We're trying to import class content from our LaunchPad to Desire2Learn in a particular module. Here is what we think needs to happen:
Create a link.
POST to /d2l/api/le/1.3/lti/link/6720
with 6720 being the org ID, which returns the link ID.
This is successful.
Create a quick link.
POST to /d2l/api/le/1.3/lti/quicklink/6720/228
with 228 being the link ID from above.
This is successful.
Create a link topic.
POST to /d2l/api/le/1.3/6720/content/modules/638/structure/
with 638 being the parent module ID obtained from LTI parameter custom_links_import_service_url, query string parameter parentNode, and using the PublicUrl in the response from the quick link call.
This results in a 404, which per the documentation, suggests a OU or parent module ID issue.
I appreciate any help with this. I can't find any good developer how-to guides in the documentation, just the API reference.
I have tried other advise here in stackoverlow and they have not helped, for example: desire2learn api adding content
404 Posting Content to Desire2Learn
404 Error when trying to post a file topic
This particular call seems to enforce content-type of application/json. All other API POSTs I've been using are ok with text/plain. It is just this route (so far) that throws an error.
(I'm not sure a 404 is the proper error for this, either.)
Thanks, Viktor for your comment, and yes, both the route and the other parameters from the LTI parameters were correct.
Related
Let's say I have an API where you can get users:
GET /RESTAPI/user/
And you can delete users by:
DELETE /RESTAPI/user/123
What is the RESTful convention on what the DELETE's response body should contain?
I expected it should be the new list of all users which now doesn't contain the user with id 123 anymore.
Googling around didn't get me any satisfying answers. I only found opinions on how to do that, but isn't there a strict definition of RESTful Services?
This is NOT a duplicate of What should a RESTful API POST/DELETE return in the body? and What REST PUT/POST/DELETE calls should return by a convention?
since this questions asks for a strict definition regarding DELETE. Those questions were answered by loose opinions only.
The reason you get no hard answers is because there is no hard RESTful standard. So I can only suggest that you create a hard standard and stick to it within your own APIs
I used this as a guide for RESTful services http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api
It says respond with a 204 status and an empty body
I stick to those standards and document them well for anyone who wants to use my APIs
What is the RESTful convention on what the DELETE's response body should contain?
REST is an architectural style defined by Fielding in the chapter 5 of his dissertation and it describes a set of contraints for applications built with this architecture. REST is designed to be protocol indenpendent but the chapter 6 of the same dissertation describes how REST is applied over HTTP.
Once your REST application is designed on the top of the HTTP protocol, you should be aware of the HTTP semantics. And the semantis of the HTTP/1.1 protocol are currently described in the RFC 7231.
The response payload of a DELETE request that has succeeded may:
Be empty or;
Include a representation of the status of the action.
And the following response status codes are suitable for a DELETE request that has succeeded:
202: The request has been accepted for processing, but the processing has not been completed.
204: The server has successfully fulfilled the request and that there is no additional content to send in the response payload body.
200: The request has succeeded and the request payload includes a representation of the status of the action.
See the following quote from the RFC 7231:
If a DELETE method is successfully applied, the origin server SHOULD
send a 202 (Accepted) status code if the action will likely succeed
but has not yet been enacted, a 204 (No Content) status code if the
action has been enacted and no further information is to be supplied,
or a 200 (OK) status code if the action has been enacted and the
response message includes a representation describing the status.
204 No Content is a popular response for DELETE and occasionally PUT as well.
However, if you are implementing HATEOAS, returning a 200 OK with links to follow may be more ideal. This is because a HATEOAS REST API provides context to the client. Think of the location a user application navigates to after successfully issuing a delete command. Here is a brief article excerpt with more discussion on this. See the blog article for a more complete discussion.
Article: http://blog.ploeh.dk/2013/04/30/rest-lesson-learned-avoid-204-responses/
Avoid 204 responses if you're building a HATEOAS application.
This is a lesson about REST API design that I learned while building non-trivial REST APIs. In order to be as supportive of the client as possible, a REST API should not return 204 (No Content) responses.
From the service's perspective, a 204 (No Content) response may be a perfectly valid response to a POST, PUT or DELETE request. Particularly, for a DELETE request it seems very appropriate, because what else can you say?
However, from the perspective of a proper HATEOAS-aware client, a 204 response is problematic because there are no links to follow. When hypermedia acts as the engine of application state, when there are no links, there's no state. In other words, a 204 response throws away all application state.
This article covers POST, PUT, DELETE and GET. Here's the specific discussion on DELETE:
Responding to DELETE requests
A DELETE request represents the intent to delete a resource. Thus, if the service successfully handles a DELETE request, what else can it do than returning a 204 (No Content)? After all, the resource has just been removed.
A resource is often a member of a collection, or otherwise 'owned' by a container. As an example, http://foo.ploeh.dk/api/tags/rock represents a "rock" tag, but another way of looking at it is that the /rock resource is contained within the tags container (which is itself a resource). This should be familiar to Atom Pub users.
Imagine that you want to delete the http://foo.ploeh.dk/api/tags/rock resource. In order to accomplish that goal, you issue a DELETE request against it. If all your client gets back is a 204 (No Content), it's just lost its context. Where does it go from there? Unless you keep state on the client, you don't know where you came from.
Instead of returning 204 (No Content), the API should be helpful and suggest places to go. In this example I think one obvious link to provide is to http://foo.ploeh.dk/api/tags - the container from which the client just deleted a resource. Perhaps the client wishes to delete more resources, so that would be a helpful link.
How can we "like" or add other reactions to someone else's channel message or comment via the Graph API?
I've not done this myself, but it certainly looks possible. You need to reply to the message, as per https://learn.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-1.0&tabs=http and notice that it has a "reactions" collection. That would be populated with a chatMessageReaction type, as per https://learn.microsoft.com/en-us/graph/api/resources/chatmessagereaction?view=graph-rest-beta
Note of warning: chatMessageReaction is a beta type though, so just be aware you need to call the beta endpoint, and it has a risk to use in production code as things might change.
Update: We reached out to MS Support and received the following info: "The API to reply to a message using a POST /replies request is solemnly for issuing a reply to a message, and not to edit the status of the parent message itself. Moreover, the "update chatMessage" API which is a PATCH /messages and which is the only API to edit a parent message only supports updating the policyViolation property of a chatMessage. Essentially, there is currently no documented API / already-present API examples on how to add a reaction, making this purely unsupported."
Aim: Use Rails to retrieve list of notes in a defined section. As seen in lines 249-287 of GetPagesExample.cs
Problem: Receiving 401 when I attempt a GET. Documentation indicates "401 - Unauthorized Problems occurred in authenticating the token, user or your app".
I'm using the OneNoteAPISampleRuby as baseline, to achieve this. The sample comes with examples of how to POST but no examples of how to GET. Posting from the sample app in my local environment works fine. I know that doing a GET on this request URL https://www.onenote.com/api/v1.0/sections/{sectionId}/pages works in the OneNote API Console. This is the URL i'm trying to get to work from my modifications to the sample app.
My modifications are as follows:
<button type="submit" name="submit" value="quotes">Get Quotes</button> at line 10 of index.html.erb
when 'quotes'
result = onenote_client.get_page_in_section(access_token)
at line 29 of welcome_controller.rb
I added a get_page_in_section method to one_note_sharer.rb as seen here: https://gist.github.com/komplexb/347b7dd61ed3338ab6f4
It uses the rest-client gem for the POST examples, so I've been looking at the docs for how to use GET but it appears I've hit a wall.
I noticed someone had a similar problem here, however that answer hasn't been useful for me, since scope office.onenote should give me read access at least according to the documentation.
Looks as if the issue was with how headers and params are combined for GET requests in rest-client library, as seen here. Corrected get_page_in_section method.
I need to open an external link, and send some params through post method. I have read that I can use redirect() to open a link through get method, as the following code:
def get = {
redirect(url: "http://localhost:8080/test/public/cadastro/dataConfirm.html?" + "username=" + "test")
}
Apparently, redirect only works with get. Is there any command to do this by post method? Thanks.
Is your goal to have the user actually redirected to a different site via POST, or POST to a different site and get results back but stay in your site? If it is actually pushing the user to a different site then Victor's comment is the way to go.
If you are trying to send a POST to a different site, get results and stay on your site look into the Rest plugin and check out the withHttp method. There is a good example here.
There can be dependency issues when using the Rest plugin. If you have these check out the answer by ataylor in this stackoverflow post.
Server-to-server comunication via post in grails can be achieved using the following java code
. I tested it and works fine in grails. The alternatives are plugins, as #Kelly answered me, and
Apache Http Components
.
I have problems building the header and/or body of the http-POST for a Twitter oAuth update_with_media call in Lua.
I'm using multipart/form-data as Content-Type
All oauth_* parameters are included in the body, including an oauth_signature.
POSTing to url https://upload.twitter.com/1/statuses/update_with_media.json
The problem is I have no idea how to successfully add the image data (media[]) to the body, in addition to 'status' and the other oauth parameters.
Also, how do I calculate the Content-Length?
As of yet, I'm constantly getting a 500 Internal Server Error back form Twitter.
Can anyone provide me with a code snippet to add image data (jpg) to a POST? I'm using the Corona SDK btw, if that makes any difference.
If any help, please refer to this issue:
Twitter API `status/update_with_media` return `404 Not Found`
If your still get the 500 error, please refer to this one:
https://dev.twitter.com/discussions/1525