I'm trying to retrieve a list of UGC posts by calling the following API
https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List%28urn%3Ali%3Aorganization%3A[ORG_ID]%29
[ORG_ID] is id of my organization. Then I got this error
{
"serviceErrorCode": 0,
"message": "java.lang.ClassCastException: java.lang.String cannot be cast to com.linkedin.data.DataComplex",
"status": 500
}
I've already authorized to use API V2 and include X-Restli-Protocol-Version:2.0.0 in the header.
I was having issues with this too, the parens on the authors query param shouldn't be encoded.
I.e., try:
https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A[ORG_ID])
I tested it with the URL mentioned https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(urn%3Ali%3Aorganization%3A[ORGANISATION ID]) and it works but make sure you set the header.
X-Restli-Protocol-Version: 2.0.0
I had to do this manually however since postman apparently doesn't work and perhaps other http tools are having similar issues.
https://github.com/postmanlabs/postman-app-support/issues/5752
The error returned by postman is the following or if you forget to include the header above: {"serviceErrorCode":0,"message":"java.lang.ClassCastException","status":500}
Related
im sending a POST request to this URL: https://verify.twilio.com/v2/Services/[REDACTED]/Verifications
and with that POST request I'm setting the required parameters in a JSON Object as the body.
My issue is that when I send the request with all the correct required parameters like this
{
"To": "[REDACTED VALID PHONE NUMBER]",
"Channel": "sms"
}
I get the following error.
{
"code": 20001,
"message": "Missing required parameter To in the post body",
"more_info": "https://www.twilio.com/docs/errors/20001",
"status": 400
}
If I try using Insomnia and setting the body to MultiPartForm and type in all my required parameters just like before it works. The issue is I cant use multipart forms and I need to use JSON, anyone have an idea why the API is acting like this?
Here is the API docs:
https://www.twilio.com/docs/verify/api/verification
After further testing, YAML and XML don't work either.
This answer isn't very satisfying, but this is how the API works. It would be best if you used content-type=application/x-www-form-urlencoded as it is also done in the documented samples.
It would be nice if it were explicitly mentioned somewhere like it was in the past.
Here's a suggestion then, build yourself a Node.js Twilio Function that takes in a webhook from Twilio, translates the content from application/x-www-form-urlencoded to application/json, and sends it on to your application
Running into an issue when trying to call the Posts API.
I'm getting a list of the authenticated user's posts through https://api.linkedin.com/rest/posts?q=author&author=AUTHOR_URN (https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-07&tabs=http#find-posts-by-authors) which worked yesterday but not anymore today.
I am convinced I changed something between then and now, but whatever I do I cannot seem to get the request to work anymore.
The error returned does not give me a lot of information either:
{
"message": "Internal Server Error",
"status": 500,
"code": "INTERNAL_SERVER_ERROR"
}
I also created a request to fetch images yesterday, which does still work:
https://api.linkedin.com/rest/images/ids=List(IMAGE_URN) (https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/images-api?view=li-lms-2022-07&tabs=http#batch-get-images)
URN I'm using for the /posts request is formatted as follows: urn%3Ali%3Aorganization%3A<REDACTED> (where <REDACTED> is the numeric author identifier).
Confirmed the headers are the same between the /posts request and /images request.
Headers for reference:
Authorization: Bearer ACCESS_TOKEN_REDACTED
X-Restli-Protocol-version: 2.0.0
LinkedIn-Version: 202207
Is there anything I'm missing here that I need to get my /posts request working?
Thanks in advance!
Talked to someone from LinkedIn support since the issue occurred for me. Their response:
It's possible that you were getting that error due to a small hiccup on our side at that time - This can happen when we deploy updates or fixes.
Since then I've not seen this happen anymore, so expecting this is the case. Closing as answered.
The LinkedIn docs state how to collect comments of a comment here, but they seem to be incorrect. It says to make a GET request that looks like this:
https://api.linkedin.com/v2/socialActions/urn:li:comment:(activity:6273189577469632512,6275822846992351232)/comments
but when I try that all I get back is a 400 error with the message:
Syntax exception in path variables
Is this the correct formatting of the comment urn? I've tried encoding it like with other requests, but that returns back the same result. Seeing a working example of this request would really help.
After talking to LinkedIn API's support, I have the answer to why this wasn't working. A lot of the documentation contains these notes:
All API requests are represented in protocol 2.0.0 and require the
header X-Restli-Protocol-Version: 2.0.0.
I thought that those notes meant that all v2 requests are meant to have their headers contain X-Restli-Protocol-Version: 2.0.0, but in actuality, it is only the endpoints where that is specified in the pages of the documentation. In other words, using that header for endpoints where it isn't needed can cause some of the requests to fail in ways that aren't clear from the error message. Removing that from the header gave the correct response.
I've tried the below request (with two different proper API keys), on the HERE Places API, but I get an auth error.
Request:
https://places.sit.ls.hereapi.com/places/v1/autosuggest
?at=40.74917,-73.98529
&q=chrysler
&apiKey=g51V9*****N4-_GTA
Response:
401
{
"error": "Unauthorized",
"error_description": "ApiKey is missing."
}
I've also tried OAuth, I can get the request token, but when I use this for the places request I get an HTML webpage (for HERE place API) as the response, rather than an expected JSON or XML reponse.
Is anyone able to get any of the example requests to work for Places API?
I had this issue before aswell. Trying the exact same request as you, in Postman with my own apiKey, made the request successfull.
Try making the URL a single line, there might be newline characters hidden somewhere.
This has solved this issue for me many times using this API.
Example:
https://places.sit.ls.hereapi.com/places/v1/autosuggest?at=40.74917,-73.98529&q=chrysler&apiKey=g51V9*****N4-_GTA
You need to check the key name it may wrong
you should check it out into the documentation of api. and see key name
try key name apikey or api_key or api-key instead of apiKey
https://places.sit.ls.hereapi.com/places/v1/autosuggest
?at=40.74917,-73.98529
&q=chrysler
&apikey=g51V9*****N4-_GTA
Please refer to this guide for the updated list of domains to use with apiKey.
For places, the domain is: places.ls.hereapi.com
Disclosure: I'm a product manager at HERE Technologies
In my case I was using : https://github.com/julianshen/gin-limiter with the provided example
I have an registered account with the here-api's and just today created a new apiKey, because we where still using the old authentication method.
No matter what authentication we use though, we receive an ERR_CONNECTION_REFUSED error when trying to access the suggestion.json-endpoint. Other endpoints work fine.
I.e. this request works fine:
https://geocoder.ls.hereapi.com/6.2/geocode.json?searchtext=200%20S%20Mathilda%20Sunnyvale%20CA&gen=9&apiKey={API_KEY}
but this fails:
http://autocomplete.geocoder.ls.hereapi.com/6.2/suggest.json?query=Pariser+1+Berl&beginHighlight=<b>&endHighlight=</b>&apiKey={API_KEY}
using, the same API key obviously, with the aforementioned ERR_CONNECTION_REFUSED error.
What's also confusing me is that removing a character from the apiKey in the first request leads to a senseful response
{
"error": "Unauthorized",
"error_description": "ApiKey invalid. ApiKey not found."
}
Whereas doing this in the second request still just returns the ERR_CONNECTION_REFUSED error.
Could you please try to use https instead of http in your request as -
https://autocomplete.geocoder.ls.hereapi.com/6.2/suggest.json?query=Pariser+1+Berl&beginHighlight=<b>&apiKey=apikey
As Example for Javascript is also using https and which is working.
https://developer.here.com/documentation/examples/rest/geocoding_suggestions