Missing likes/comments in LinkedIn API response - linkedin

since 4 days my job which is fetching linkedIn updates is getting null responses for likes and comments (requests on specific updates : /updates/key={update-key}/likes and /updates/key={update-key}/update-comments endpoints). This is probably expected since when requesting on /updates/key={update-key}, the response does not have likes nor comments field.
My question is how can I get those values for specific updates (which I managed to get previously) since I can get them differently (maybe? read following)
Here's the strangest part : when I don't specify the update (request only on /updates endpoint), I get the following response : (modified a bit for readability/privacy)
{
"_count": 10,
"_start": 0,
"_total": 212,
"values": [
{
"isCommentable": false,
"isLikable": false,
"isLiked": false,
"likes": {
"_total": 3,
"values": [...]
},
"numLikes": 7,
"timestamp": ...,
"updateComments": {"_total": 0},
"updateContent": {...},
"updateKey": ...
"updateType": ...
},{
"isCommentable": false,
"isLikable": false,
"isLiked": false,
"likes": {
"_total": 3,
"values": [...]
},
"numLikes": 9,
"timestamp": ...,
"updateComments": {"_total": 0},
"updateContent": {...},
"updateKey": "...",
"updateType": "..."
}, ....
So first, the updates have their fields isCommentable, isLikable and isLiked set to false, despite the fact that they have likes/comments.
Second, there is an inconsistency between the fields likes._total and numLikes (the latter one is the correct amount of likes)
Does anyone else encountered a similar problem? (well linkedin api update comment count null) Is it something expected or a change from LinkedIn side?
I already ask to LinkedIn help center which redirected me to StackOverflow.
Thanks for your time.

Ok, I retried today :
{
"isCommentable": true,
"isLikable": true,
"isLiked": false,
"likes": {
"_total": 9,
"values": [
{ ...
So definitely an issues on linkedin side, fixed for now.

Same issue.
If you get a specific company update (with comment and like)
//api.linkedin.com/v1/companies/xxxx/updates/key=yyyy?format=json
{
"isCommentable": false,
"isLikable": false,
...
}
If you get comments for a specific company update
//api.linkedin.com/v1/companies/xxxx/updates/key=yyyy/likes?format=json
Result null
If you get likes for a specific company update
//api.linkedin.com/v1/companies/xxxx/updates/key=yyyy/update-comments?format=json
Result null

Related

Azure CosmosDB - Partial Document Update (Patch) on Complex Structures

I'm trying to use the Partial Document Update (Patch API) to update a child object in my document, but I'm running into trouble. I found this Stack Overflow question which is the same question that I have. However, the accepted answer resolves the problem by referring to an object in an array by index. I don't believe that I have the luxury of being able to do that. So, to use the same example document as the other question...
{
"id": "SalesOrder2",
"ponumber": "PO15428132599",
"OrderDate": "2005-07-01T00:00:00",
"DueDate": "2005-07-13T00:00:00",
"ShippedDate": "2005-07-08T00:00:00",
"AccountNumber": "Account2",
"SubTotal": 6107.082,
"TaxAmt": 586.1203,
"Freight": 183.1626,
"TotalDue": 4893.3929,
"DiscountAmt": 1982.872,
"Items": [
{
"Id": 1,
"OrderQty": 3,
"ProductCode": "A-123",
"ProductName": "Product 1",
"CurrencySymbol": "$",
"CurrencyCode": "USD",
"UnitPrice": 17.1,
"LineTotal": 5.7
},
{
"Id": 2,
"OrderQty": 2,
"ProductCode": "A-456",
"ProductName": "Product 2",
"CurrencySymbol": "$",
"CurrencyCode": "USD",
"UnitPrice": 10,
"LineTotal": 20
}
],
"_rid": "BsMkAMc43s4CAAAAAAAAAA==",
"_self": "dbs/BsMkAA==/colls/BsMkAMc43s4=/docs/BsMkAMc43s4CAAAAAAAAAA==/",
"_etag": "\"00000000-0000-0000-e136-0dbec04601d7\"",
"_attachments": "attachments/",
"_ts": 1637760030
}
I have no guarantee that the item in the Items array with an Id of 1 would be in position 0 of the array. Similarly, the item with an Id of 2 is not guaranteed to be in position 1. Therefore I believe that I need to use the FilterPredicate parameter of the Patch API to filter my results. But when I attempt to do that, I keep getting the following exception:
Microsoft.Azure.Cosmos.CosmosException : Response status code does not
indicate success: PreconditionFailed (412); Substatus: 1110;
ActivityId: dbd258ae-0a0a-4a9b-8c25-1d36e137b7c5; Reason: ();
Any assistance you could provide on how to accomplish this would be appreciated.
As i answered in the attached link, Patch requires the user to pass the specific index of the object needs to be updated. We are working on enabling this particular feature in the coming months, However as an alternative, you should look at Conditional Patch
Code will be something like this,
response = patch(operation, Condition(check if item exists))
if(response == fail/precondition failed)
{
PatchOperation operation = PatchOperation.Add("/Items", [{"Id" : "P-1", "Description" : "My Product"}]);
}

Find and delete Discord webhook message

I'm using a Discord webhook to send information which may later be invalidated, so I want to be able to delete it. To do this i use these endpoints:
First i make a post request to send a message:
POST /webhooks/{webhook.id}/{webhook.token}
And then i want to do a delete request to remove the message again:
DELETE /webhooks/{webhook.id}/{webhook.token}/messages/{message.id}
However I don't have the ID of the message i want to delete, since no response is given to the first POST request which is always an empty 204 response. Is it possible to get the message id?
Any help would be appreciated.
Per this reddit post:
If you need to reference a message ID of a webhook message you sent, you can add ?wait=true to the end of the URL which will give you the message data (including the ID) instead of a 204 (No Content) when you don't include the query parameter.
So if you send your normal POST request to your url like this: POST /webhooks/{webhook.id}/{webhook.token}, add ?wait=true to the end of that. Then you will get back data like this:
{
"id": "MESSAGEID",
"type": 0,
"content": "This is a test",
"channel_id": "CHANNELID",
"author": {
"bot": true,
"id": "AUTHORID",
"username": "USERNAME",
"avatar": "AVATARID",
"discriminator": "0000"
},
"attachments": [],
"embeds": [],
"mentions": [],
"mention_roles": [],
"pinned": false,
"mention_everyone": false,
"tts": false,
"timestamp": "2021-11-13T18:10:24.412000+00:00",
"edited_timestamp": null,
"flags": 0,
"components": [],
"webhook_id": "WEBHOOKID"
}

Adding parameters to the POST Analyze method

https://westus2.dev.cognitive.microsoft.com/docs/services/form-recognizer-api/operations/AnalyzeWithCustomModel
In the above documentation there is the following URL which implies you ought to be able to analyze a form for a specific Key value
https://{endpoint}/formrecognizer/v1.0-preview/custom/models/{id}/analyze[?keys]
I have trained a model of my own and when I use the Get Keys method this is what gets returned...
{"clusters":{"0":["House Name","Mobile Number","Name","Phone Number","Postcode","Street","Sumame","Town Name","e-Mail Address (required)"]}}
It seems to me that I ought to be able to execute that post against any one of those key values. So....
https://{endpoint}/formrecognizer/v1.0-preview/custom/models/{id}/analyze?keys=Name
Should pull back whatever the value is associated with the Name key (and there is a value) but instead I get a 200 success and no workable information.
"status": "success",
"pages": [
{
"number": 1,
"height": 756,
"width": 471,
"clusterId": null,
"keyValuePairs": [],
"tables": []
}
],
"errors": []
}
I think I am misunderstanding how to do this properly
Are you able to see the key and an associated value when you try the /analyze call without the query param "keys"?

Why does LinkedIn's organizationalEntityShareStatistics endpoint return -1 for values in certain requests?

I am using the organizationalEntityShareStatistics endpoint but noticed that certain requests will return -1 for a value. Is this another way of indicating null? For example, the following request for my personal organization returns a shareCount of -1.
https://api.linkedin.com/v2/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=urn%3Ali%3Aorganization%3A35526437
{
"elements": [
{
"totalShareStatistics": {
"shareCount": -1,
"uniqueImpressionsCount": 434,
"clickCount": 25,
"engagement": 0.029905178701677606,
"shareMentionsCount": 0,
"likeCount": 10,
"impressionCount": 1371,
"commentMentionsCount": 0,
"commentCount": 7
},
"organizationalEntity": "urn:li:organization:35526437"
}
],
"paging": {
"count": 10,
"start": 0,
"links": []
}
}
I have also noticed this happening when querying share statistics for a specific share but I cannot provide that specific request because it is client data.
So to reference their docs for the likeCount:
This field can become negative when members who liked a sponsored share later unlike it. The like is not counted since it is not organic, but the unlike is counted as organic.
MRW
...so I would assume this also applies to shareCount and who knows what other fields as well.

ImmutableJS how to simplify a filter and update logic

The following is my structure of data
[
{
"id": 1,
"title": "Welcome to my playground",
"description": "This is so fun to play with, you will like it <3",
"comments": [
{
"id": 1140406,
"comment": "this is an example comment",
"postId": 1
}
]
},
...
]
And I'm trying to use immutable js to do this operation
Get all the posts
Search for a post I want to add comment to
Adding the comments when the post is found
The following is my code
posts = posts.map((post) => {
if(post.get('id') == payload.post_id) {
return post.update('comments', (comments) => {
return comments.push(Map({
id: payload.id,
comment: payload.comment
}));
});
}
return post;
});
But I assume this pattern is very common and there should be a simpler way to do this in immutableJS. Any advice will be helpful, thanks.
First off, it's worth mentioning that your Data structure is Immutable Lists and Maps.. not JS Arrays and Objects.
OK, without changing your data structure you could do:
posts.map(post => post.get('id') === payload.post_id ?
post.update('comments', comments.push(payload) :
post)
If you were to change your data structure, and instead of having a List of posts, had a Map of post's with their ID as the key you could just do:
post.updateIn([payload.post_id, 'comments'], comments => comments.push(payload))
BTW you can use push or concat here, both will function the same.
Also, if comments may be undefined, you can provide a "noSetValue" as a List (https://facebook.github.io/immutable-js/docs/#/List/updateIn):
posts.map(post => post.get('id') === payload.post_id ?
post.update('comments', Immutable.List([]), comments.push(payload) :
post)
post.updateIn([payload.post_id, 'comments'], Immutable.List([]), comments => comments.push(payload))
For others who has the same question: One should consider a data normalisation (search for normalizr). You could then normalise your data to something like:
"entities": {
"posts": {
"1": {
"id": 1,
"title": "Welcome to my playground",
"description": "This is so fun to play with, you will like it <3",
"comments": [1140406, 1140407, 1140408]
},
"42" : {...}
}
"comments": {
"1140406": {
"id": 1140406,
"comment": "this is an example comment",
"postId": 1
},
"1140407": {...}
}
}
then updating post and comments becomes much easier

Resources