I try to get data from OData.
The link is as below.
https://*********.cloudax.dynamics.com/data/PurchaseOrderHeadersV2?$select=PurchaseOrderNumber,RequestedDeliveryDate,DeliveryAddressDescription&$filter=OrderVendorAccountNumber%20eq%20%27100001%27
I only add 3 fields to the select clause. But the "#odata.etag" field has added to the response. The response is as below.
{
"#odata.context":"https://****.cloudax.dynamics.com/data/$metadata#PurchaseOrderHeadersV2(PurchaseOrderNumber,RequestedDeliveryDate,DeliveryAddressDescription)","value":[
{
"#odata.etag":"W/\"JzE5MDYyOTE2NzcsNTYzNzMwMzU3NjswLDA7MSw1NjM3MTYzMzI2OzAsMDswLDAn\"","PurchaseOrderNumber":"PO00003871","RequestedDeliveryDate":"2020-10-07T12:00:00Z","DeliveryAddressDescription":"******"
},{
"#odata.etag":"W/\"JzE5NjkzNDMzOTUsNTYzNzMwMzU3NzswLDA7MSw1NjM3MTYzMzI2OzAsMDswLDAn\"","PurchaseOrderNumber":"PO00003872","RequestedDeliveryDate":"2020-09-16T12:00:00Z","DeliveryAddressDescription":"*******"
},{
"#odata.etag":"W/\"JzIwNzgyNTg4OSw1NjM3MzAzNTc4OzAsMDsxLDU2MzcxNjMzMjY7MCwwOzAsMCc=\"","PurchaseOrderNumber":"PO00003873","RequestedDeliveryDate":"2020-10-08T12:00:00Z","DeliveryAddressDescription":"*****"
},{
"#odata.etag":"W/\"JzE3MjYzMjQ0NzUsNTYzNzMwMzU3OTswLDA7MSw1NjM3MTYzMzI2OzAsMDswLDAn\"","PurchaseOrderNumber":"PO00003874","RequestedDeliveryDate":"2020-10-08T12:00:00Z","DeliveryAddressDescription":"**********"
},{
"#odata.etag":"W/\"JzEsNTYzNzMwNDMyNjswLDA7MSw1NjM3MTYzMzI2OzAsMDswLDAn\"","PurchaseOrderNumber":"PO00003881","RequestedDeliveryDate":"2020-10-09T12:00:00Z","DeliveryAddressDescription":"*********"
}
]
}
How can I remove this metadata information from response?
You can try these headers, which will eliminate metadata from response.
Content-Type: application/json; odata.metadata=minimal
In fact you can mention odata.metadata=none for further
apiurl?$format=application/json;odata.metadata=none
Related
So I'm quite a fan of the Graph API to manage Onedrive from my server.
Now I'm trying to use the Graph API to move a file from one directory to another one following the documentation here.
Now in order to do so, I send (PATCH) the following to https://graph.microsoft.com/v1.0/me/drive/items/01A2ASUEXPG7EKMCTPDJDY7L5YMVTNWHMO:
{'parentReference': {'id': '01A2ASUEVXTMODEW6HIJC3MSXT5JJ4JLRK'}}
And I receive:
{
"#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('b9dc908f-6c6f-463b-a568-9361fabdc995')/drive/items/$entity",
"#microsoft.graph.downloadUrl":"xxxx",
"createdDateTime":"2022-04-20T08:46:12Z",
"eTag":"\"{A6C837EF-6F0A-471A-8FAF-B86566DB1D8E},1\"",
"id":"01A2ASUEXPG7EKMCTPDJDY7L5YMVTNWHMO",
"lastModifiedDateTime":"2022-04-20T08:46:12Z",
"name":"IMG.png",
"webUrl":"https://xxxx-my.sharepoint.com/personal/xxxx-uitzendbureau_nl/Documents/Loonstroken%20(alleen%20voor%20toevoegen)/xxxx/IMG.png",
"cTag":"\"c:{A6C837EF-6F0A-471A-8FAF-B86566DB1D8E},1\"",
"size":382692,
"createdBy":{
"user":{
"email":"Online#xxxx.nl",
"id":"b9dc908f-6c6f-463b-a568-9361fabdc995",
"displayName":"Online beheer"
}
},
"lastModifiedBy":{
"user":{
"email":"Online#xxxxx.nl",
"id":"b9dc908f-6c6f-463b-a568-9361fabdc995",
"displayName":"Online beheer"
}
},
"parentReference":{
"driveType":"business",
"driveId":"b!u2WpOb6qnkS_6foMbPUq90TwxghBinBMhj9DwokQnQefs7rIOSQYS5kmJNV5uSJ7",
"id":"01A2ASUEWGZQX5GCGE2RFL6J3WBIW2LTUC",
"path":"/drive/root:/Loonstroken (alleen voor toevoegen)/xxxxxx"
},
"file":{
"mimeType":"image/png",
"hashes":{
"quickXorHash":"Yk0eRqT2ThqJHamo0AMLstI0CBI="
}
},
"fileSystemInfo":{
"createdDateTime":"2022-04-20T08:46:12Z",
"lastModifiedDateTime":"2022-04-20T08:46:12Z"
},
"image":{
},
"shared":{
"scope":"users"
}
}
As you can see:
'parentReference': {'driveType': 'business', 'driveId': 'xxx', 'id': '01A2ASUEWGZQX5GCGE2RFL6J3WBIW2LTUC', 'path': '/drive/root:/Loonstroken (alleen voor toevoegen)/xxxxxx'}
The parentReference ID has not changed to the one provided in the request, but still a 200 is returned. Also the file obviously was not moved.
Any idea what might be the issue here?
Answering my own question.
Seems this was an issue on Microsoft's end. I now get a correct parentReference in the response.
While using swagger-editor I create the below YAML that shows an example of the response object. It's properly displaying in the swagger-editor. When I then download the JSON and display it in swagger-ui, the example is completely missing.
/person/{email}/create:
post:
summary: Create a new account
tags:
- Person
parameters:
...
responses:
201:
description: The new SQL ident and sport details
examples:
application/json: |
[
12,
[
{
"sql_idnet" : 12,
"name" : "Basketball"
},
{
"sql_ident" : 13,
"name" : "Ice Hockey"
}
]
]
This might be because the response does not have a schema - in Swagger this means the response does not have a body.
That said, Swagger UI 3.0 displays this example correctly.
Swagger UI and Swagger Editor currently do not support multiple examples. You can follow this issue for updates.
Whenever I try a post a complex character to create a list entry in an O365 SharePoint list (via REST API) I get a JSON parse error from the server. The following is the simple post and it is the β (beta) character which causes the fail. &mdash (—) and other non-simple characters also cause the fail.
The code works just fine for alphabetic characters. It appears to me to be a parsing issue on the SharePoint side but I wanted to know if I was missing something stupid (it happens...)
If I remove the β character from Title field it works just fine. If I create the list item manually through the SP web interface it works just fine, so I know that it is not that the character is invalid, just the creation of the list item through the API.
The headers for the post are:
var outHeaders = {
"Content-Type": "application/json;odata=verbose",
"Accept": "application/json;odata=verbose",
"Authorization": 'Bearer ' + token,
"Content-Length": data.length,
"X-RequestDigest": digest,
"IF-MATCH" : "*"
}
The data being posted is as follows
{
"__metadata": {
"type": "SP.Data.EmailArchiveListItem"
},
"Title": "TEST fail email β",
"Sender": "Mark Roden",
"Recipient": "Mark Roden",
"Body": "HI Marky"
}
The error returned is:
400
Bad Request
{
"error": {
"code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
"message": {
"lang": "en-US",
"value": "Invalid JSON. Unexpected end of input was found in JSON content. Not all object and array scopes were closed."
}
}
}
Any input/thoughts appreciated.
Try using this code: β That should make it through.
In 2021 (five years later) I had a similar problem (using the SharePoint MS Graph REST API) which I fixed by specifying the charset in the content-type explicitly:
application/json; charset=utf-8
Joe Jorden's answer at least got me this far - If you post the β or — into an RTF Field it works - posting it into a plain text field does not.
For automation purposes I'm trying to create issues through the JIRA REST API, but I'm getting a 500, Internal Server Exception as response without any additional information.
With the Chrome-plugin "advance REST client", I ran through the following steps:
Entered the endpoint: h.ttps://[company-jira-url]/rest/api/2/issue/
Set the HTTP method: POST
Added the required headers:
Content-Type: application/json
Authorization: Basic (100% sure this one's correct)
Added the json payload (Basically the minimum required fields):
{
"fields": {
"project":
{
"key": "HACK"
},
"summary": "REST EXAMPLE",
"description": "Creating an issue via REST API",
"issuetype": {
"name": "Bug"
}
}
}
Click "Send"
The request basically looks like this (base64 string is not correct in this example):
The Request
Result:
The Response
Anyone ?
I could insert rows by QueryString sql parameter. https://developers.google.com/fusiontables/docs/v1/reference/query/sql?hl=ja
But the reference document describes that you can use sql parameter as body of POST for inserting rows. I can't. How do I do? https://developers.google.com/fusiontables/docs/v1/using?hl=ja#insertRow
First reference describes that QueryString sql parameter required. I got error 400 by omitting sql in QueryString. Using QueryString has limitation(URL length). I want to insert many rows in body of POST.
request:
POST https://www.googleapis.com/fusiontables/v1/query?access_token={my access token} HTTP/1.1
Content-Type: application/json
sql=INSERT INTO 1JOgUG5QWE5hybrDAd2GX3yfjVCGoM6u7WkSVDok ('_id', '_count', 'start_time', 'end_time', 'counts', 'start_plaece', 'end_place', 'distance', 'average_speed', 'send_flag', 'time_span', 'train_type', 'calories', 'weight', 'status', 'map_url', 'rally_id' ) VALUES ('-1', '0', '2013/01/19 09:00:00.000', '2013/01/19 12:34:56.000', '9876', 'Tokorozawa3', 'iidabashi2', '45678', '67', '0', '986532', '1', '389', '77.70', '0', 'http://www.google.com/', '3');
response:
body {
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: sql",
"locationType": "parameter",
"location": "sql"
}
],
"code": 400,
"message": "Required parameter: sql"
}
}
The documentation is faulty and there are some deatils missing.
You can use the sql=... parameter in the request url. The ContentType header usually is application/json but the API probably accepts other too. In this case you're limited in 2048 characters URL length.
You van also use sql=... in the POST body. In this case you have to set the ContentType must be application/x-www-form-urlencoded. You are limited to 500 INSERT statements in 1 request.
Another option is to use the importRows method. Here you will use a CSV as the POST body. In this method you're limited by 100MB uploaded data. The ContentType must be "application/octet-stream".
More details here: importRows reference