Suppose there is POST /inteview/:id/invite route.
Parameters are email addresses:
{ 'emails': ['foo#test.com', 'bar#test.com'] }
Response should indicate that some addresses are successfully invited some not. For example:
[ {
"email": "foo#test.com",
"status": "already invited"
},
{
"email": "foo#test.com",
"status": "already invited"
}
]
Which status to return for partial success?
The Response's HTTP Status Code should be 200 OK, since you are getting the expected server's response.
Whether an email is invited or not, is not an actual error.
Related
We want to know what is the best way to do :
an alert is sent to the MS teams channel, the alert contains "Approve" and "Deny"
Both "Approve" or "Deny" has "HttpPost" to send the POST to target URL
After clicking "Approve" or "Deny", how do we get the http status and print the comment "Approved" if http status is "200" ?
After clicking either approve or deny, how do we print the comment with whoever clicked(for example logged in user) so that others will know.
This is below payload :
{
"#type":"MessageCard",
"#context":"http://schema.org/extensions",
"themeColor":"0076D7",
"text":"### Build [($BUILD_NUMBER)]($CONSOLE_LINK) of [($BUILD_LINK)]($BUILD_URL) failed on [($BM_NAME)]($JENKINS_URL)",
"potentialAction":[
{
"#type":"HttpPost",
"name":"Approve",
"body": "verification.approve",
"target":"https://learn.microsoft.com/outlook/actionable-messages"
},
{
"#type": "OpenUri",
"name": "Deny",
"targets": [{
"os": "default",
"uri": "https://learn.microsoft.com/outlook/actionable-messages"
}]
}
],
}
You need to implement a Bot or Client App and then while calling the Webhook Http/Https URL, you need to capture the response & based on response code, you can take action accordingly.
I'm creating the following request in vbscript and sending to the gocardless sandbox:
url="https://api-sandbox.gocardless.com/"
typ="GET"
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.Open typ, url, False
xml.setRequestHeader "Authorization", "Bearer " & GCAccessToken
xml.SetRequestHeader "GoCardless-Version", "2015-07-06"
xml.SetRequestHeader "Accept","application/json"
xml.SetRequestHeader "Content-Type", "application/json"
xml.Send
GetGC = xml.responseText
Set xml = Nothing
The response I always get despite any tweaks I do is:
{"error":{"message":"not found","errors":[{"reason":"not_found","message":"not found"}],"documentation_url":"https://developer.gocardless.com/api-reference#not_found","type":"invalid_api_usage","request_id":"0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009","code":404}}
Any help would be appreciated. Have successfully done similar for Stripe but now need to use GC.
If you read the response from the API
{
"error": {
"message": "not found",
"errors": [{
"reason": "not_found",
"message": "not found"
}
],
"documentation_url": "https://developer.gocardless.com/api-reference#not_found",
"type": "invalid_api_usage",
"request_id": "0AA4000DECCD_AC121CEB1F90_5BE18701_19AD0009",
"code": 404
}
}
The error appears to be a HTTP status code (as is common with RESTful APIs) - 404 Not Foundlooking at the documentation link provided in the response;
404
Not Found. The requested resource was not found or the authenticated user cannot access the resource. The response body will explain which resource was not found.
So the issue could be;
You have failed to authenticate using the token in the code provided.
You authenticated but don't have permission to access the resource.
The resource you are looking for does not exist.
In this particular instance, I would suggest it is because the resource doesn't exist as the code doesn't specify a resource, only the base URL of the API which won't constitute an API endpoint you can interact with.
Looking at the documentation it's clear you need to provide a valid endpoint in the URL, at the time of writing there are 15 core endpoints to interact with along with 2 helper endpoints.
For example, a create payment request/response would look like;
POST https://api.gocardless.com/payments HTTP/1.1
{
"payments": {
"amount": 100,
"currency": "GBP",
"charge_date": "2014-05-19",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"links": {
"mandate": "MD123"
}
}
}
HTTP/1.1 201 (Created)
Location: /payments/PM123
{
"payments": {
"id": "PM123",
"created_at": "2014-05-08T17:01:06.000Z",
"charge_date": "2014-05-21",
"amount": 100,
"description": null,
"currency": "GBP",
"status": "pending_submission",
"reference": "WINEBOX001",
"metadata": {
"order_dispatch_date": "2014-05-22"
},
"amount_refunded": 0,
"links": {
"mandate": "MD123",
"creditor": "CR123"
}
}
}
Unfortunately, the code sample provided in the question doesn't really do anything so it's difficult to suggest what you are trying to do. In conclusion, I would suggest re-visiting the documentation for the API and look through the samples provided.
I'm trying to get player info for authenticated user, it successful for the first request, but then fails later.
{
"error": {
"code": 500,
"message": null
}
}
I already turning on OAuth 2.0, set the playerId to 'me', but it returns 500.
Is there something wrong? Is there any limit requests for this one? Is anything missing?
Thanks,
POST /api/teams
{
"name": "",
"leagueId": 1
}
Rules:
name is required
leagueId is required
authenticated user should be the owner of the league where the created team will be associated to.
Let's say the authenticated user doesn't have access to leagueId because the user is not the the owner, is it better to return a 403 response (note that the rule for the name field is also not satisfied)?
Or its better to return 422 status code and this payload:
{
"errors": [
{
"field": "name",
"message": "Name is required."
},
{
"field": "leagueId",
"message": "User is not the owner of the league."
}
],
"message": "Validation Failed"
}
I would return a 400 bad request when a required field is not present as the request did not satisfy the implicit contract.
And I would return 403 Forbidden in the case the authenticated user is not the owner of the league, as it indicates that the user is not allowed to do this because of who he/she is.
I have problem with the ESPN API:
I have an API key, and sent a query to the address http://api.espn.com/v1/sports/news/1581816?region=GB, which included my API key in the parameters.
I received 403 forbidden response: with this JSON
{
"status": "error",
"code": 403,
"message" : "Account Inactive"
}
I am looking at http://developer.espn.com/docs/headlines#using-the-api and at the last line it says that i can make a GET request to this url and it should work, but it doesn't.
How can I receive a valid response from the ESPN servers?
I just test it and it works fine. That means your key is invalid, or you are not including it. Replace below and it will work.
http://api.espn.com/v1/sports/news/1581816?region=GB&apikey=<yourKey>
--
{
timestamp: "2013-10-13T15:33:49Z",
resultsOffset: 0,
status: "success",
resultsLimit: 10,
resultsCount: 1,
headlines: [
{ ... }
]
}