Amity API I have some problem with this API /api/v3/users/list - chatsdk

I wanted to get multiple user information with one request, so I used /api/v3/users/list. [According to https://api-docs.amity.co/#/]
It worked fine the first time. However, if there is a wrong user id in the request, the API will return 400. In other words, if I want to search these user IDs 1234 and 4567 but 4567 does not exist, API will return 400. Is it possible to return the existing ones and ignore the non-existing ones?

Related

HTTP status code response when there is not matched data with DB

I am building an API about email auth code.
Its process is simple.
input random code (client browser)
request with input code. (client browser)
receive the request (server)
scan the code from DB (server)
there is no code matched (server)
return a response with status code.
There are many status code, (2xx, 4xx, 5xx);
but I don't know which status code number is the most proper for this case.
It depends on the semantics you want to give your request. E.g.:
The API should search for items matching the query and return a list of results, like GET /codes?q=4ba69g. Think a "search page". In this case, an empty result [] is a perfectly valid result; nothing was wrong with the query, it just didn't return any matches. That's a 200 OK, or maybe a 204 No Content if you want to omit the empty response body entirely.
The code is treated like a resource, e.g. GET /codes/4ba69g. In this case a missing code would result in a 404 Not Found.
It's an action you want to perform which may fail, e.g. POST /login. If the user supplied the wrong credentials/code and hence the action cannot complete, that's a client-side error and therefore a 400 Bad Request.

How do I get the documentID in Business Objects Restful API?

I'm trying to figure out how to download a PDF from the BOE restful API.
I've been following the answer from ƘɌỈSƬƠƑ here:
SAP BI Open Doc URL for retrieving pdf
I was able to accomplish step 1 (getting the token).
But on the second step, it mentions using the documentID.
e.g.
/biprws/raylight/v1/documents/5690743/parameters
On the front end of BOE, if I click on the report, and choose Properties, it shows me that the "ID/CUID" is:
ID, CUID:746001, AdgNq_GsaqhOqnzc4gRN_Jg
Does that mean the "DocumentID" is 746001?
I'm not sure if I'm using the correct ID, because when I hit:
/biprws/raylight/v1/documents/746001/parameters
I get:
<error>
<error_code>100</error_code>
<message>Rule not respected (Argument 'reportIds' must not be null)</message>
</error>
You don't need to obtain prompt information (/parameters endpoint).
I think you are using the correct ID since the error is on the report. You obtain a 404 Not Found response status, if the document does not exist.
After a successful login, simply call /biprws/raylight/v1/documents/5690743 and add to your request an header with name Accept and value application/pdf. Of course the X-SAP-LogonToken should also be provided.
It will export the whole document. If you only need a specific report, you need to retrieve its ID first. Call the URI /biprws/raylight/v1/documents/5690743/reports with Accept header equals to application/json.
Choose one of the report, and get its ID (for example, in my case reportID equals 1234). Then you can export the report as a PDF by calling the URI: /biprws/raylight/v1/documents/5690743/reports/1234 with Accept header equals to application/pdf.

Office 365 REST API /$count filter giving wrong data

I'm trying to get count of records for different objects. The response of /$count filtered APIs is inconsistently giving wrong response.
I am referring this documentation link for usage instructions.
Request URL: GET https://outlook.office.com/api/v2.0/me/Events/$count
Response: -1
To verify if the above mentioned response is legitimate, I tried to get all events with a skip filter to identify the actual number of records present.
After a certain attempts following request URL gave me final count:
Request URL: GET https://outlook.office.com/api/v2.0/me/events/?$skip=159
Response:
{
"#odata.context": "https://outlook.office.com/api/v2.0/$metadata#Me/Events",
"value": [
{
"Id": "AAMkADMzYzIxNTBjLWUyMWUtNDgzYi04NTEwLTc5YTkzMWI5MmE4MgBGAAAAAABjOnbtK9ZkTIjwInd5bfYcBwDe_ScfFfAUQaKHRwnzV1lBAAAAAAENAADe_ScfFfAUQaKHRwnzV1lBAACs2ojfAAA=",
"CreatedDateTime": "2016-11-28T11:09:03.8359488Z",
"LastModifiedDateTime": "2017-02-21T08:04:48.8262751Z"
}
]
}
This implies that after skipping 159 records, I've 160th record present in the authenticated account but $count filtered API doesn't give me a valid response.
I tried testing this scenario with two different accounts where I noticed this anomaly for /message API as well. The HTTP GET call to messages/$count gives me 1563 whereas after trying with skip filter I found the total count to be 1396
I want to know if $count returns a legitimate response? If yes then explain this anomaly If no then is there any pattern where we should expect response to inconsistent?
To get a count of the number of events, you need to specify start time and end time. Here is what I use:
https://outlook.office.com/api/v2.0/me/calendarview/$count?startDateTime=2017-05-01T00:00:00Z&endDateTime=2017-05-31T23:59:59Z
If you don't specify the dates, you will get 400 with the following error message:
{"error":{"code":"ErrorInvalidParameter","message":"This request requires a time window specified by the query string parameters StartDateTime and EndDateTime."}}

Twitter API followers/ids - All Followers Returned but next_cursor is still present

I have been working with the Twitter API [followers/ids] for a few of our accounts but recent got stuck with a confusing state.
Usually twitter returns a next_cursor when there are still some records remaining in next page(s). It works fine with iteration but recently when I tried to request followers/ids for one of our accounts which doesn't have a lot of followers (just over 4200) and all can be returned in single request. Even though, the API returns all the followers in a single request but strangely the next_cursor is still present.
So when I try to make another (2nd) request with that cursor, only one record is returned which is not present in the first set of records.
What should I consider that how much followers the user actually have?
Total Followers: 4224
1st Request: 4224 [next_cursor: present]
2nd Request with cursor: 1
This is creating confusion as it is 4224 or 4225?
Attaching a screenshot

What is the correct value or status code to indicate that a username record could not be updated?

I'm implementing a basic service to add usernames to user records in a database. The service first checks if the username exists and if it does returns some value to tell the client that the username is already taken. If the username is available it updates the user record and returns "OK". In this application the client is a native IOS mobile app and the server is node.js. But that shouldn't be relevant to this question.
For this service, what would you recommend I use as my return values? For example, when successful should I return a status code 200? A boolean value? A custom string? Similarly for the unsuccessful condition what would the recommended and customary return value be?
The status 201 is intented to be used when some resource is created. So when your user is created you should set status code 201 and set it to 200 when the same request does an update. Additionally you can return the ID id the created/updated user. IMHO you should keep create and update as separate services.
You can use apporpriate 4xx errors (Refer link) when errors happen. Always keep a status message attribute in your response if your response is XML or JSON. You can set appropriate messages into this and the mobile app can check this message based on the HTTP Status Code you give.
I would return a 201 for the successful condition and a 400 or 409 for the unsuccessful condition.
Hope that helps!
Brandon