How do I escape a Sharepoint column name in Microsoft Graph? - rest

I'm performing the following request to update the value of "ExampleColumn#" for a Sharepoint Online item:
PATCH https://graph.microsoft.com/v1.0/sites/{site_id}/lists/{list_id}/items/{item_id}
With the following request body:
{
"fields":{
"ExampleColumn#": 1
}
}
Returns a 400 bad request error, with the following message:
"message": "A metadata reference property was found in a JSON Light request payload. Metadata reference properties are only supported in responses"
As I believe Odata requires the "#" symbol to be escaped, I've tried using percent-encoding which I couldn't get to work.
Request Body:
{
"fields":{
"ExampleColumn%23": 1
}
}
Response:
"message": "Field 'ExampleColumn%23' is not recognized"
What should I be doing differently in my request body?

#Zak,
Please make sure the field in the request body is the correct internal name of that column. I am able to update a column value in my SPO list via the below request:
You can get the field internal name through its setting page:

Related

What is the expected request to get GoToWebinar webinar details based on organiser_key?

I am trying to fetch GoToWebinar details via the
Get Webinars method
​/organizers​/{organizerKey}​/webinars
listed on the GoToWebinar API reference.
I'm passing the below body:
{
"fromTime":"2015-07-13T10:00:00Z",
"toTime":"2015-07-13T22:00:00Z"
}
But in response, I get the below error:
{
"errorId": "26a9b9a8-3a92-45b0-acdd-7ac3c3f485ac",
"requestId": null,
"timeStamp": 1587960550357,
"reason": "invalid.data",
"errorCode": "invalid.data",
**"description": "Required DateTime parameter 'fromTime' is not present",**
"incident": "5801952841989547523",
"details": null
}
The API reference guide does not specify any request structure, just mentions what is needed to be sent, and I have built my logic on the same. Yet I am unable to get a proper response.
Can anybody help me in understanding what the expected request should be?
Since this is a GET HTTP call you can not add these parameters to the Body. I mean you can but it won't be sent along with the call (only with POST/PUT). So you should add the two fields you provided to the Query Parameters instead.

SugarCRM REST API v11 filtering records

I am using postman application to do a SugarCRM POST request, following is the request
https://{site_url}/rest/v11/{module_name}/filter?filter=[{"$is_null"="logoutdttime"}]&fields=name,username,logoutdttime&order_by=date_entered&max_num=10
I am getting the error
{
"error": "invalid_parameter",
"error_message": "Unexpected filter type string."
}
but when I remove the filter, I get the response
https://{site_url}/rest/v11/{module_name}/filter?fields=name,username,logoutdttime&order_by=date_entered&max_num=10
what am I doing wrong
The filter is defined as array via the key and in an assoc array style rather than json. That's weird, but that's how it works in Sugar Query-String params.
Try:
https://{site_url}/rest/v11/{module_name}/filter?filter[0][$is_null]=logoutdttime&fields=name,username,logoutdttime&order_by=date_entered&max_num=10
Alternatively you can use the POST /filter endpoint instead of GET.
Then you can pass all params in the request body as json.
PS: Also are you sure you mean $is_null and not $empty?
try this:
filter[0][name][$starts]=any text
Document:
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_12.0/Integration/Web_Services/REST_API/Endpoints/Accountsrecordlinklink_namefilter_GET/

How to reiterate json response to extract a token and to make a restapi call with for-each activity

i am using Copy Data activity(Can't use Web activity due to security reasons) to connect to Rest API(source) (via REST dataset)and I get a response in json format as shown below which is what i need, only that this is the first page and there are many other pages that i need to retrieve. The retrieved information is then saved in SQL database table (destination). In process to retrieve the next pages i need to extract the token from "continuationToken" and send it back to my REST dataset as an dynamic value. Not sure if this is the correct way but gave it a try.
[
{
"pagedResponse":[
{
"docType":"current",
"orgNumber":"98789765",
"persons":[
],
"clientId":43533,
"name":null,
"clientResponsible":{
"id":null,
"name":null
}
}
],
"continuationToken":{
"token":"-RID:Om1+ANeDbNMWASEAAAAAAAAA==#RT:1#TRC:10#ISrV:2#IEO:6554436",
"range":{
"min":"",
"max":"05C1DFFFFFFFFFFC"
}
}
}
]
I tried to run some test by saving the json response as a file. Created Lookup activity(Lookup1) to read in the json file and in the then created a for-each activity and in the items i added a dynamic content
#activity('Lookup1').output.value[0].continuationToken
but got this error message.:
{
"errorCode": "InvalidTemplate",
"message": "The function 'length' expects its parameter to be an
array or a string. The provided value is of type 'Object'.",
"failureType": "UserError",
"target": "ForEach1"
}
expected result was:
"token":"-RID:Om1+ANeDbNMWASEAAAAAAAAA==#RT:1#TRC:10#ISrV:2#IEO:6554436",
"range":{"min":"","max":"05C1DFFFFFFFFFFC"}
I think your solution mentioned in the question should work.I suppose that you want to know whether the continuationToken is null so that the loop should be ended,so you use length function.However,according to the error message:The function 'length' expects its parameter to be an array or a string. The provided value is of type 'Object'. It is stated in the document clearly:
Then continuationToken is an object,should be used with empty function:

"E_INVALID_NEW_RECORD",

{
"code": "E_INVALID_NEW_RECORD",
"details": "Missing value for required attribute EMP_ID. Expected a number, but instead, got: undefined",
"message": "The server could not fulfill this request (POST /employee/create) due to a problem with the parameters that were sent. See the details for more info. The following additional tip will not be shown in production: Tip: Check your client-side code to make sure that the request data it sends matches the expectations of the corresponding attribues in your model. Also check that your client-side code sends data for every required attribute."
}

How to update share point 2013 list item in rest service

This is my Rest service to update list item
URL: https://site/_api/lists/getbytitle('Test')/items(49)
Header
X-RequestDigest: some unique id from contextinfo post service
Content-Type: application/json;odata=verbose
X-HTTP-Method: MERGE
IF-MATCH: 49
Body
{
"__metadata": {
"type": "SP.Data.TestListItem"
},
"Title": "Title all1",
"Option1": "Updated 2"
}
When I run this URL in post man I get an error
The request ETag value __metadata.etag does not match the object's ETag value
"8".
But If I change IF-MATCH value in header as *, it's updating properly. Why I am getting an error if use ETag?
You are using the ETag incorrectly. The ETag will correspond to the item's Version not the item's ID.
The best way to test this is to do a get request for the item and look at the metadata for the ETag property. You will see something similar to this
{
"__metadata": {
"id":"Web/Lists(guid'xxxxxxxx')/Items(1)",
"uri":"https://site.sharepoint.com/site/subsite/_api/Web/Lists(guid'xxxxxx')/Items(1)",
"etag":"\"12\""
}
}
Notice the formatting of the ETag.
I can't think of any good reason to use the IF-MATCH for a specific ETag in the case of updating the item. The request parameter for the ID should be more than sufficient. Checking versioning with ETags is needed when wanting to PUT, MERGE, or DELETE a specific version of an item.
Check this Working with lists and list items with REST for more information.