I have some problem with the "Find Entities by URNs" API in order to retrieve the metadata and value information for a collection of URNs.
If I use the URL described in the doc (Sample request) with a valid access token:
https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=List(urn%3Ali%3AfieldOfStudy%3A100990,urn%3Ali%3Aorganization%3A1035,urn%3Ali%3Aseniority%3A9)&locale=(language:en,country:US)&oauth2_access_token=<a-valid-token>
I receive the message:
{
"serviceErrorCode": 0,
"message": "java.lang.ClassCastException",
"status": 500
}
Anyone have experience the same issue? Any idea how to fix it?
Also: how can i contact for technical support as in this case?
UPDATE:
I made some try and I fix using the following version:
https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=urn%3Ali%3AfieldOfStudy%3A100990&urns=urn%3Ali%3Aorganization%3A1035&urns=urn%3Ali%3Aseniority%3A9&locale.language=it&locale.country=IT&oauth2_access_token=<a-valid-token>
BUT the locale/language translation is not working. Could be this a working solutions?
From the support team:
Our docs are missing 1 critical piece of information. Whenever using
LIST and encoded URNs in the URL, we expect an additional header 'x-restli-protocol-version: 2.0.0'
The correct API call would be Request:
curl -X GET \
'https://api.linkedin.com/v2/adTargetingEntities?q=urns&urns=List(urn%3Ali%3Aindustry%3A1,urn%3Ali%3Aseniority%3A9)&locale=(language:it,country:IT)'
\
-H 'x-restli-protocol-version: 2.0.0' \
-H 'Authorization: Bearer <Token>'
Response:
{
"elements": [
{
"facetUrn": "urn:li:adTargetingFacet:industries",
"name": "Difesa e spazio",
"urn": "urn:li:industry:1"
},
{
"facetUrn": "urn:li:adTargetingFacet:seniorities",
"name": "Partner",
"urn": "urn:li:seniority:9"
}
],
"paging": {
"count": 2147483647,
"links": [],
"start": 0
}
}
Yes, it does provide a response in locale.
Hope this can help other guys in the future
Related
I'm trying to create a stack from a template using the Heat API. I'm using the API reference here as a guide. I have the following json in a file called single-server-template.json:
{
"stack_name": "api-test",
"template": {
"heat_template_version": "rocky",
"description": "Testing Heat API\n",
"resources": {
"server1": {
"type": "OS::Nova::Server",
"properties": {
"name": "Server1",
"image": "Ubuntu 22.04 (Jammy)",
"flavor": "alt.st1.small",
"key_name": "my_key",
"networks": "Internal"
}
}
}
}
}
I'm sending it with this: curl -X POST -H "X-Auth-Token:$OS_TOKEN" -d #single-server-template.json https://$OS_HOST_URL:8004/v1/$OS_PROJECT_ID/stacks
I've been at it for hours but no matter what I send I get a 400 error:
{"code": 400, "title": "Bad Request", "explanation": "The server could not comply with the request since it is either malformed or otherwise incorrect.", "error": {"type": "HTTPBadRequest", "traceback": null, "message": "The server could not comply with the request since it is either malformed or otherwise incorrect."}}
Things I've tried:
confirmed my environment vars are filled in correctly before sending
confirmed that the template itself is valid by spinning it up from the UI console
confirmed that other endpoints that require auth work as expected
screaming and/or crying
Can anyone confirm that what I've got is correct, or test it against your own openstack instance? The only other thing I can think of is that maybe my openstack provider has an issue with their API
I would like to retrieve UGC posts from organization's profile using the ugcPosts API. I would also like to receive links to video streams with the response, so I use the following projection (based on this answer):
(paging,elements*(id,created,specificContent(com.linkedin.ugc.ShareContent(shareMediaCategory,shareCommentary,media(*(media~:playableStreams,originalUrl,description,title,thumbnails))))))
My whole request looks like this (retrieving the posts of the official test organization):
curl --request GET \
--url 'https://api.linkedin.com/v2/ugcPosts?q=authors&sortBy=LAST_MODIFIED&projection=(paging%2Celements*(id%2Ccreated%2ClastModified%2Cauthor%2CspecificContent(com.linkedin.ugc.ShareContent(shareMediaCategory%2CshareCommentary%2Cmedia(*(media~%3AplayableStreams%2CoriginalUrl%2Cdescription%2Ctitle%2Cthumbnails))))))&authors=List(urn%3Ali%3Aorganization%3A2414183)' \
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
--header 'X-Restli-Protocol-Version: 2.0.0'
The request works as fine. But I run into an issue if I want to follow to the next page using the provided URL in paging; this is the relevant response:
{
"paging": {
"total": 284243,
"count": 10,
"start": 0,
"links": [
{
"rel": "next",
"type": "application/json",
"href": "/v2/ugcPosts?q=authors&start=10&count=10&sortBy=LAST_MODIFIED&projection=%28paging%2Celements*%28id%2Ccreated%2ClastModified%2Cauthor%2CspecificContent%28com.linkedin.ugc.ShareContent%28shareMediaCategory%2CshareCommentary%2Cmedia%28*%28media~%3AplayableStreams%2CoriginalUrl%2Cdescription%2Ctitle%2Cthumbnails%29%29%29%29%29%29&authors=List(urn%3Ali%3Aorganization%3A2414183)"
}
]
}
}
On the first page, you can see that parentheses in the projection parameter got URL encoded, while authors parameter remains the same. This request still works, but if I follow the URL one more time, I recieve the following paging data:
{
"paging": {
"total": 284243,
"count": 10,
"start": 10,
"links": [
{
"rel": "prev",
"type": "application/json",
"href": "/v2/ugcPosts?q=authors&start=0&count=10&sortBy=LAST_MODIFIED&projection=%2528paging%252Celements*%2528id%252Ccreated%252ClastModified%252Cauthor%252CspecificContent%2528com.linkedin.ugc.ShareContent%2528shareMediaCategory%252CshareCommentary%252Cmedia%2528*%2528media~%253AplayableStreams%252CoriginalUrl%252Cdescription%252Ctitle%252Cthumbnails%2529%2529%2529%2529%2529%2529&authors=List(urn%3Ali%3Aorganization%3A2414183)"
},
{
"rel": "next",
"type": "application/json",
"href": "/v2/ugcPosts?q=authors&start=20&count=10&sortBy=LAST_MODIFIED&projection=%2528paging%252Celements*%2528id%252Ccreated%252ClastModified%252Cauthor%252CspecificContent%2528com.linkedin.ugc.ShareContent%2528shareMediaCategory%252CshareCommentary%252Cmedia%2528*%2528media~%253AplayableStreams%252CoriginalUrl%252Cdescription%252Ctitle%252Cthumbnails%2529%2529%2529%2529%2529%2529&authors=List(urn%3Ali%3Aorganization%3A2414183)"
}
]
}
}
You can see here that the projection parameter got URL-encoded again (having %252C for parens) and following that URL returns error 400.
I think this is a bug in the API, but since LinkedIn recommends to use Stack Overflow for support, I just wrote this up here, hopeful someone notices. Perhaps could you suggest another way of contacting LinkedIn about this bug in their API?
Meanwhile I resorted to constructing the pagination URL manually.
Using this link: https://learn.microsoft.com/en-us/azure/cognitive-services/form-recognizer/quickstarts/curl-train-extract I follow each step and use the sample data in the guide. All of them are successful until the last step which is "Get the Analyze results", where it returns the following:
{
"status": "failed",
"createdDateTime": "2020-07-09T14:59:12Z",
"lastUpdatedDateTime": "2020-07-09T14:59:14Z",
"analyzeResult": {
"version": null,
"readResults": null,
"pageResults": null,
"documentResults": null,
"errors": [
{
"code": "2003",
"message": "Download failed. Please check your input URL."
}
]
}
}
Unfortunately, there are no references to error codes and possible explanation/solutions. Assistance is highly appreciated.
The error message is quite clear: the url that you provided for the analysis does not allow the service to download the document.
Please check the content that you sent during the operation called "Analyze forms for key-value pairs and tables":
curl -v "https://<Endpoint>/formrecognizer/v2.0/custom/models/<model ID>/analyze" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <subscription key>" -d "{ \"source\": \""<SAS URL>"\" } "
In particular, can you detail the last part? The piece with the '' block is the one causing the error
I am very beginner to Google Firestore (also to Firebase). I am doing a simple POC and I am suffering a bit to interact with FireStore. Well, reading the data from Angular worked as a charm so easy. Nevertheless, simple actions like add a new data from curl or deleting the collection from FireBase Cli has taken me the whole day without progress . Just to stress how dummy I am in FireStore, I have used ElasticSearch local installed so I am trying similar behaviours/tools/functionalities like posting/creating fields from curl/postman (it is not part of this question compare one another, just exposing my limitations) but I just can't move forward.
This is how I connected successfully from Angular:
firebaseConfig : {
apiKey: "*** removed ***",
authDomain: "transfer-status-realtime.firebaseapp.com",
databaseURL: "https://transfer-status-realtime.firebaseio.com",
projectId: "transfer-status-realtime",
storageBucket: "transfer-status-realtime.appspot.com",
messagingSenderId: "143612370857",
appId: "1:143612370857:web:a9d0b21e3a58520ed02eb8",
measurementId: "G-WT5C346D7T"
}
I have based mainly my tentatives in Making Rest Calls and other stack overflow question
My last and recent tried:
c:\temp>curl -X POST -H "Content-Type: application/json" -d'{"fields": {"status": "success"}}' "https://firestore.googleapis.com/v1beta1/projects/transfer-status-realtime/databases/(default)/documents/transfers?&key=***removed***"
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 8
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Closing quote expected in string.\n\n^",
"status": "INVALID_ARGUMENT"
}
}
So my main issue: how add data to FireStore from curl?
In case it matter, here is my database console:
Other tentatives probably in wrong direction I have tried are:
According to https://firebase.google.com/docs/database/rest/save-data, I can save fields by using PUT so I tried write a curl command and I got stuck because I don't know what would be the "fireblog" in my case?
curl -X PUT -d '{
"transfers": {
"id": "idfromPut",
"status": 1
}
}' 'https://transfer-status-realtime.firebaseio.com/rest/saving-data/fireblog/users.json'
I also tried but what would be message_list in my case?
curl -X POST -d '{"status" : 2}' 'https://transfer-status-realtime.firebaseio.com/message_list.json'
*** edited
c:\temp>curl -X POST -H "Content-Type: application/json" -d "{\"fields\": {\"status\": \"success\"}}" "https://firestore.googleapis.com/v1/projects/transfer-status-realtime/databases/(default)/documents/transfers?&key=*** removed ***"
{
"error": {
"code": 400,
"message": "Invalid value at 'document.fields[0].value' (type.googleapis.com/google.firestore.v1.Value), \"success\"",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document.fields[0].value",
"description": "Invalid value at 'document.fields[0].value' (type.googleapis.com/google.firestore.v1.Value), \"success\""
}
]
}
]
}
}
In case it is relevant, same issue using external json file
C:\WSs\reactive-stack\reactive-front\src>curl -X POST -H "Content-Type: application/json" -d #load-data-tofirestore.json "https://firestore.googleapis.com/v1/projects/transfer-status-realtime/databases/(default)/documents/transfers?&key=***removed"
{
"error": {
"code": 400,
"message": "Invalid value at 'document.fields[0].value' (type.googleapis.com/google.firestore.v1.Value), \"success\"",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document.fields[0].value",
"description": "Invalid value at 'document.fields[0].value' (type.googleapis.com/google.firestore.v1.Value), \"success\""
}
]
}
]
}
}
And here is the json file
{"fields": {"status": "success"}}
* SOLUTION *
from cUrl
C:\WSs\reactive-stack\reactive-front\src>curl -H "Content-Type: application/json" -X POST https://firestore.googleapis.com/v1/projects/transfer-status-realtime/databases/(default)/documents/transfers -d "{\"fields\": { \"status\": { \"stringValue\": \"outro status\" } }}"
{
"name": "projects/transfer-status-realtime/databases/(default)/documents/transfers/ddwHxjy7eQV3640pW0Xx",
"fields": {
"status": {
"stringValue": "outro status"
}
},
"createTime": "2020-04-06T16:21:16.453553Z",
"updateTime": "2020-04-06T16:21:16.453553Z"
}
from PowerShell
PS C:\Users> $body = #"
>> {
>> "fields": {
>> "status": {
>> "stringValue": "fracasso"
>> }
>> }
>> }
>> "#
>>
PS C:\Users\Cast> $params = #{
>> Uri = 'https://firestore.googleapis.com/v1/projects/transfer-status-realtime/databases/(default)/documents/transfers'
>> Method = 'POST'
>> Body = $body
>> ContentType = 'application/json'
>> }
>>
PS C:\Users\Cast> Invoke-RestMethod #params
name fields createTime
---- ------ ----------
projects/transfer-status-realtime/databases/(default)/documents/transfers/z4TB6gzcgXMRUGR8ecek #{status=} 2020-04-06...
PS C:\Users>
I believe the root cause of your issue is due to cURL on a windows system. As seen in this other question, there are limitations on how the command line arguments are parsed in a windows shell.
Instead of using this:
-d'{"fields": {"status": "success"}}'
You should state your payload as:
-d "{\"fields\": {\"status\": \"success\"}}"
Another solution could be writing the JSON in a file and using its path in the cURL query. I believe you could keep the right JSON format this way, but you would be forced to use a file, which is far from optimal if you don't intend to send the same payload multiple times:
-d #file_with_data.json
I'm trying the following request:
GET https://api.linkedin.com/v2/people/(id:urn:li:person:<person id>)?oauth2_access_token=<token>&projection=(results*(localizedFirstName,vanityName))
But I always get a:
{
"serviceErrorCode": 100,
"message": "Unpermitted fields present in RESOURCE_KEY: Data Processing Exception while processing fields [/memberId]",
"status": 403
}
If I try to do it using the alternative API:
GET https://api.linkedin.com/v2/people?ids=List((id:urn:li:person:<person id>))&oauth2_access_token=<token>&projection=(results*(localizedFirstName,vanityName))
An Internal Server Error is returned:
{
"message": "Internal Server Error",
"status": 500
}
I'm using Google Chrome to perform those requests.
I tried using Postman too.
Headers:
X-Restli-Protocol-Version: 2.0.0
Authorization: Bearer <token>
Got:
{
"serviceErrorCode": 0,
"message": "Syntax exception in path variables",
"status": 400
}
My app permissions are:
r_emailaddress
r_ads
w_organization_social
rw_ads
r_basicprofile
r_liteprofile
r_ads_reporting
r_organization_social
rw_organization_admin
w_member_social
I tried other APIs (socialActivity, ugcPosts) and everything looks fine.
I checked my API usages at https://www.linkedin.com/developers/apps/<id>/usage and people usage is currently 0%.
The tested user profiles are also public.
You should only use the id (instead of the urn). also the fields projection is wrong:
Use:
projection=(localizedFirstName,vanityName)
Instead of:
projection=(results*(localizedFirstName,vanityName))
As example:
curl -H "X-Restli-Protocol-Version: 2.0.0" \
"https://api.linkedin.com/v2/me?oauth2_access_token=<TOKEN>&projection=(id)"
Will return
{
"id": <ID>
}
and use it as:
curl -H "X-Restli-Protocol-Version: 2.0.0" \
"https://api.linkedin.com/v2/people/(id:<ID>)?oauth2_access_token=<TOKEN>&projection=(localizedFirstName,vanityName)"
So:
{
"vanityName": "<VANITY-NAME>",
"localizedFirstName": "<NAME>"
}
Hope this help
id parameter needs only person_id but you are providing urn.Try this https://api.linkedin.com/v2/people/(id:person_id) and don't forgot to include X-RestLi-Protocol-Version:2.0.0 in header while making call.