Remove properties related to Sharepoint from raw odata response - node.js

I am using Sharepoint REST API to get/modify data in Sharepoint from NodeJS.
I am getting odata response from Sharepoint REST API and everything is working as expected.
Except one thing.
Currently I am getting response from Sharepoint REST API as below
{
"odata.metadata": "https://test.sharepoint.com/_api/$metadata#SP.ApiData.Lists",
"value": [
{
"odata.type": "SP.List",
"odata.id": "https://test.sharepoint.com/_api/Web/Lists(guid'sample-guid')",
"odata.etag": "\"6\"",
"odata.editLink": "Web/Lists(guid'sample-guid')",
"AllowContentTypes": true,
"BaseTemplate": 160,
"BaseType": 0,
"ContentTypesEnabled": true,
"CrawlNonDefaultViews": false,
"Created": "2015-05-19T11:13:46Z",
"DefaultContentApprovalWorkflowId": "00000000-0000-0000-0000-000000000000",
"Description": "Use this list to track access requests to a site or uniquely permissioned items in the site.",
"Direction": "none",
"DocumentTemplateUrl": null,
"DraftVersionVisibility": 0,
"EnableAttachments": false,
"EnableFolderCreation": false,
"EnableMinorVersions": false,
"EnableModeration": false,
"EnableVersioning": true,
"EntityTypeName": "AccessRequests",
"FileSavePostProcessingEnabled": false,
"ForceCheckout": false,
"HasExternalDataSource": false,
"Hidden": true,
"Id": "sample-id",
"IrmEnabled": false,
"IrmExpire": false,
"IrmReject": false,
"IsApplicationList": false,
"IsCatalog": false,
"IsPrivate": false,
"ItemCount": 1,
"LastItemDeletedDate": "2015-05-19T11:13:46Z",
"LastItemModifiedDate": "2015-08-04T06:57:22Z",
"ListItemEntityTypeFullName": "SP.Data.AccessRequestsItem",
"MajorVersionLimit": 0,
"MajorWithMinorVersionsLimit": 0,
"MultipleDataList": false,
"NoCrawl": true,
"ParentWebUrl": "/",
"ParserDisabled": false,
"ServerTemplateCanCreateFolders": true,
"TemplateFeatureId: "sample-id",
"Title": "Test Title"
}, {
........
}]
}
In the above response I am getting fields which are related to Sharepoint System along with fields I want.
for ex: odata.type, odata.id, AllowContentTypes, BaseTemplate etc.
How do I get the fields which I required but not the other Sharepoint related fields.
Can anybody help ?
Thanks

For that purpose you could utilize $select query option (follow OData Version 2.0 for a more details).
Regarding odata.type and odata.id properties, since they are part
of metadata properties, you just need to specify the proper Accept
header in order to request them (eg: accept:
application/json;odata=minimalmetadata). For a more details follow JSON
Light support
in REST SharePoint API released article.
The following example returns a specific set of List resource properties such as AllowContentTypes and BaseTemplate:
Endpoint URI: https://contoso.sharepoint.com/_api/web/lists?$select=AllowContentTypes,BaseTemplate
Accept: application/json; odata=minimalmetadata
Method: GET
Result
{
"d": {
"results": [
{
"__metadata": {
"id": "https://contoso.sharepoint.com/_api/Web/Lists(guid'82dcfcc5-e58c-4610-b4c3-589a7228e912')",
"uri": "https://contoso.sharepoint.com/_api/Web/Lists(guid'82dcfcc5-e58c-4610-b4c3-589a7228e912')",
"etag": "\"0\"",
"type": "SP.List"
},
"AllowContentTypes": true,
"BaseTemplate": 125
},
//...
]
}
}

Related

How to get catalog search results by keywords via Amazon SP API that like Amazon website search results?

First method "listCatalogItems" produces correct results but limits max 10 ASINs. And now this method is deprecated.
Other method "searchCatalogItems" produces INcorrect random results.
fyi listCatalogItems says it's deprecated but it still works
I am getting correct results when I use searchCatalogItems. Here is my postman call: https://sellingpartnerapi-na.amazon.com/catalog/2022-04-01/items?marketplaceIds=ATVPDKIKX0DER&keywords=samsung
and part of my results:
{
"numberOfResults": 54592886,
"pagination": {
"nextToken": "9HkIVcuuPmX_bm51o3-igBfN45pxW4Ru7ElIM6GCECYCuXJKzT26f-3Tfs1Ro3IhelNA74VxDMJwt_JvE7qiRh0loZTzTpEBWUbZ8HB0T4ttV8cFw4xYQ4RMUzdY_udbnvAHOHCcZcycn0nW8RotZh1l1vj7KQoFIa7pWiOPHyaYWP7sBE9Fg7cGN2wE0an5ePw96h6ZL7m6olRxFOcqTWNanEVRjipq"
},
...
"items": [
{
"asin": "B09YN4W5C1",
"summaries": [
{
"marketplaceId": "ATVPDKIKX0DER",
"adultProduct": false,
"autographed": false,
"brand": "SAMSUNG",
"itemClassification": "VARIATION_PARENT",
"itemName": "SAMSUNG Jet Bot Robot Vacuum Cleaner",
"manufacturer": "SAMSUNG",
"memorabilia": false,
"packageQuantity": 1,
"tradeInEligible": false,
"websiteDisplayGroup": "home_display_on_website",
"websiteDisplayGroupName": "Home"
}
]
},
{
"asin": "B01AQ6OWAG",
"summaries": [
{
"marketplaceId": "ATVPDKIKX0DER",
"adultProduct": false,
"autographed": false,
"brand": "SAMSUNG",
"browseClassification": {
"displayName": "Remote Controls",
"classificationId": "10967581"
},
"itemClassification": "BASE_PRODUCT",
"itemName": "SAMSUNG TV Remote Control BN59-01199F by Samsung",
"manufacturer": "Samsung",
"memorabilia": false,
"modelNumber": "BN59-01199F",
"packageQuantity": 1,
"partNumber": "BN59-01199F",
"tradeInEligible": false,
"websiteDisplayGroup": "ce_display_on_website",
"websiteDisplayGroupName": "CE"
}
]
},

Imgur seems to be letting me search private images, have they screwed up?

According the imgur website:
When you upload a post to Imgur, you have two post privacy options: Hidden and Public.
A hidden post means that your post is not shared with the general Imgur community and can only be accessed via the URL. Hidden posts cannot be searched,...
Using only my client id (no OAuth), I hit the gallery search endpoint using the tag '#wow' (ie GET https://api.imgur.com/3/gallery/t/wow/). I get the same results as when visiting this publicly accessible page: https://imgur.com/t/wow.
Viewing the metadata for these images that I get from my api request, almost all (56 / 60) have a privacy value of "hidden"
Could be concerning, though wondered if an imgur expert could explain this before I try contact imgur about it.
Portion of the API json response:
{"data":
{"name": "wow",
"display_name": "wow",
"followers": 29719,
"total_items": 17077,
"following": false,
"is_whitelisted": true,
"background_hash": "QL9pTeJ",
"thumbnail_hash": nil,
"accent": "159559",
"background_is_animated": false,
"thumbnail_is_animated": false,
"is_promoted": false,
"description": "",
"logo_hash": nil,
"logo_destination_url": nil,
"description_annotations": {},
"items":
[{"id": "yWPI5rf",
"title": "Lake basement.",
"description": nil,
"datetime": 1656844974,
"cover": "IrUShgg",
"cover_width": 720,
"cover_height": 960,
"account_url": "DacianFalx",
"account_id": 64529075,
"privacy": "hidden", // 56 / 60 items have the same privacy value
"layout": "blog",
"views": 50557,
"link": "https://imgur.com/a/yWPI5rf",
"ups": 481,
"downs": 6,
"points": 475,
"score": 499,
"is_album": true,
"vote": nil,
"favorite": false,
"nsfw": false,
"section": "",
"comment_count": 116,
"favorite_count": 40,
"topic": nil,
"topic_id": nil,
"images_count": 1,
"in_gallery": true,
"is_ad": false,
"tags":
[{"name": "wow",
"display_name": "wow",
"followers": 29719,
"total_items": 17076,
"following": false,
"is_whitelisted": false,
"background_hash": "QL9pTeJ",
...omitted...

Creating a list column returns undesired result

I am in need of creating a custom column for a SharePoint list. I need to add custom metadata to the files I will be saving under that list. I followed the instructions in the official documentation; Nonetheless, I'm getting an unexpected result when it comes to a certain property specifically.
My intention is to create a Multiple lines text column. This is the body I am sending on the PATCH request:
{
"columnGroup": "Custom Columns",
"description": "Custom app metadata",
"displayName": "App Data",
"enforceUniqueValues": false,
"hidden": false,
"indexed": false,
"name": "AppData",
"readOnly": false,
"required": false,
"text": {
"allowMultipleLines": true,
"appendChangesToExistingText": false,
"linesForEditing": 6,
"textType": "plain"
}
}
However, the response I am getting back is this:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.list)('777xxx77-x77x-7xx7-xx77-7x7x7x7x7x')/columns/$entity",
"columnGroup": "Custom Columns",
"description": "Custom app metadata",
"displayName": "App Data",
"enforceUniqueValues": false,
"hidden": false,
"id": "777xxx77-x77x-7xx7-xx77-7x7x7x7x7x", //replaced original with dummy id
"indexed": false,
"name": "AppData",
"readOnly": false,
"required": false,
"text": {
"allowMultipleLines": true,
"appendChangesToExistingText": true,
"linesForEditing": 6,
"textType": "plain"
}
}
The key point here is that the property appendChangesToExistingText, which is set to false in the request body, is returned as true in the response body.
That little thing is driving me nuts. The reason for that is that I get this "View Entries" thing in the sharepoint column. I have done some research an apparently, it is caused by that property set to TRUE.
My question is.... Why is not the API working as expected? Am I doing something wrong? Is it a bug in the API? Is it not ready for production yet? Can anyone shed some light please?

Zapier is binding data response from GET request?

I am trying to manipulate a response from GET request, but Zapier is binding all the response data. Please see the image. Is this true, or there are ways around this?
This is the response from Zapier's GET.
Please point me a correct direction.
Here is the raw version:
{
"data": [
{
"id": 19235266,
"text": "Start of chat (WhatsApp)",
"photo": null,
"coordinates": null,
"transport": "whatsapp",
"type": "from_client",
"read": true,
"created": "2018-03-22T08:52:31 UTC",
"audio": null,
"pdf": null,
"remote_id": null,
"recipient_status": null,
"operator_id": 8645,
"channel_id": 1524,
"dialog_id": 903974,
"client_id": 1704911
},
{
"id": 19235267,
"text": "Chat agent – Administrator",
"photo": null,
"coordinates": null,
"transport": "whatsapp",
"type": "system",
"read": true,
"created": "2018-03-22T08:52:31 UTC",
"audio": null,
"pdf": null,
"remote_id": null,
"recipient_status": null,
"operator_id": null,
"channel_id": 1524,
"dialog_id": 903974,
"client_id": 1704911
}
]
}
Thank you in advance.
David here, from the Zapier Platform team.
Luckily, the fix here is very simple. If you want access to the raw hook (instead of the way we process it) you should use the Catch Raw Hook trigger:
Then you'll get your full body as a string:
and you can do whatever you'd like with it. For example, I wrote a small code step to pull the id of the first item:
let j = JSON.parse(inputData.data)
return {emails: j.data}
Which worked as expected. Note that if you return an array from a code step, subsequent steps will happen for each item. Proceed with caution when processing a bunch of items.

Azure Search - OrderBy filterable field then by distance

I'm trying to cater for the following example with Azure Search.
Given the following index schema:
{
"name": "mySchema",
"fields": [
{
"name": "Id",
"type": "Edm.String",
"key": true,
"searchable": false,
"filterable": false,
"sortable": false,
"facetable": false,
"retrievable": true,
"suggestions": false
},
{
"name": "StateId",
"type": "Edm.Int32",
"key": false,
"searchable": false,
"filterable": true,
"sortable": false,
"facetable": false,
"retrievable": true,
"suggestions": false
},
{
"name": "Location",
"type": "Edm.GeographyPoint",
"key": false,
"searchable": false,
"filterable": true,
"sortable": true,
"facetable": false,
"retrievable": true,
"suggestions": false
},
],
}
I want to be able to order my results firstly on the StateId field, and then by the distance from a given lat/long location.
I realise that I am able to achieve the first part by using a $filter= StateId eq x component when querying. However, I do want to still receive results (with a lower score) that are not in the provided StateId, but are of a given distance away from a provided location.
I recognise also, that this looks like it should be able to be achieved by a custom Scoring Profile. I would expect by using a Scoring Profile, I'd be able to return something like this:
[
{
"#search.score":100.0,
"Id":"111",
"StateId":"123",
"Location": {"type": "Point details...."},
},
{
"#search.score":100.0,
"Id":"222",
"StateId":"123",
"Location": {"type": "Point details...."},
},
{
"#search.score":50.0,
"Id":"333",
"StateId":"789",
"Location": {"type": "Point details...."},
}
]
However, I am not able to search on the StateId field, as this is an Edm.Int32 value, so I do not believe using a Scoring Profile would be a viable solution.
Anyone come across a similar scenario?
EDIT:
Trying to explain just a bit further - if I were to explain this in Psuedo-SQL, this is basically the case I'm trying to handle
ORDER BY (CASE WHEN StateId = #StateId THEN 1 ELSE 0 END) DESC, Location
We don't currently support modeling this scenario with scoring profiles. This has come up multiple times though, so it's something we'd like to add.
In the meanwhile, one thing you can do as a work-around is to add the StateId value to one of the searchable fields (e.g. just append it at the end of the text). Then during search include the state id as part of the search string, which should skew results towards those documents that match the state id (or that are a very good match without it, which might be good relevance anyway depending on the case).
During display, if you show this text field you'd have to strip out the state id from the end of the string (or use a different field).

Resources