I'm trying to use the insert lead api and I'm getting getting error 612 - "Invalid Content Type"
I know there are 2 different threads, as well as the explanation in the documentation that the request header needs to state "Content-Type: application/json"
I've tried both curl (as per the example in the documentation - which is wrong, btw) as well as java. Both clearly have "Content-Type" "application/json"
Any suggestions? Am I missing something? Any thoughts on how I might troubleshoot?
Any help would be really, really appreciated.
I do think it's related to Content-Type. Here is an example with Postman (chrome plug-in). I would check whether your call works as expected using Postman, then try to incorporate it into your code (Java or cURL).
Related
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.
everyone. I'm trying to use postman for hitting our prod api, but I get some error:
I did not have that problem two days ago, and I have no idea what is happening. Anyone can advise ?
It looks like a new Postman build is using a stricter header parsing, which is causing some issues for response headers that are not well formatted.
https://github.com/postmanlabs/postman-app-support/issues/8747
Turning on the "Send no-cache Header" option resolved this for me:
It's probably related to response header. Try this request in your browser and if it works, look at the response headers in devtools/network to find an invalid character.
In my case request wasn't working in Postman for one specific id. When I looked into response in devtools, I found that there was a double quote inside a double-quoted string header value and I think it caused this error, but I may well be wrong here.
Anyway, try this exact GET request in browser and see if it works there.
I had this problem when I was setting headers in golang using http like this:
w.Header().Set("X-Frame-Options", "Deny")
It worked fine in curl but not in postman and I didn't understand what was wrong. I also checked my headers using -v option in curl. Everything was correct. So I substitute Postman with Insomnia and it's working with no problem.
When you give HttpStatusCode as NoContent, this issue comes up. If you change the HttpStatusCode, it will work.
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 thought GET is not supposed to have a body. But in the context of elasticsearch, I keep seeing this kind of query (see here for instance):
curl -XGET localhost:9200/test/_msearch --data-binary #requests; echo
How is the binary data sent in this case? Can somebody explains what is going on and how this works?
I first thought it was converted to a POST but, I put a proxy in front of Elasticsearch and saw that curl was really sending a GET. Though I could find the data neither in the header, nor in the parameter, nor in the body. So it seems like my proxy also got confused by this request.
But when I execute the request directly against elasticsearch, it works just fine. What gives?
GETs with bodies are allowed but not considered to be very "meaningful". You can see this question and answer for a full discussion. HTTP GET with request body
and this answer about your proxy: https://stackoverflow.com/a/978173/3516034
maybe you guys can help me with this. I am trying to implement
reCAPTCHA in my node.js application and no matter what I do, I keep
getting "invalid-site-private-key" as a response.
Here are the things I double and double checked and tried:
Correct Keys
Keys are not swapped
Keys are "global keys" as I am testing on localhost and thought it might be an issue with that
Tested in production environment on the server - same problem
The last thing I can think of is that my POST request to the reCAPTCHA
API itself is incorrect as the concrete format of the body is not
explicitly documented (the parameters are documented, I know). So this
is the request body I am currently sending (the key and IP is changed
but I checked them on my side):
privatekey=6LcHN8gSAABAAEt_gKsSwfuSfsam9ebhPJa8w_EV&remoteip=10.92.165.132& challenge=03AHJ_Vuu85MroKzagMlXq_trMemw4hKSP648MOf1JCua9W-5R968i2pPjE0jjDGX TYmWNjaqUXTGJOyMO3IKKOGtkeg_Xnn2UVAfoXHVQ-0VCHYPNwrj3PQgGj22EFv7RGSsuNfJCyn mwTO8TnwZZMRjHFrsglar2zQ&response=Coleshill areacce
Is there something wrong with this format? Do I have to send special
headers? Am I completely wrong? (I am working for 16 hours straight
now so this might be ..)
Thank you for your help!
As stated in the comments above, I was able to solve the problem myself with the help of broofa and the node-recaptcha module available at https://github.com/mirhampt/node-recaptcha.
But first, to complete the missing details from above:
I didn't use any module, my solution is completely self-written based on the documentation available at the reCAPTCHA website.
I didn't send any request headers as there was nothing stated in the documentation. Everything that is said concerning the request before they explain the necessary parameters is the following:
"After your page is successfully displaying reCAPTCHA, you need to configure your form to check whether the answers entered by the users are correct. This is achieved by doing a POST request to http://www.google.com/recaptcha/api/verify. Below are the relevant parameters."
-- "How to Check the User's Answer" at http://code.google.com/apis/recaptcha/docs/verify.html
So I built a querystring myself (which is a one-liner but there is a module for that as well as I learned now) containing all parameters and sent it to the reCAPTCHA API endpoint. All I received was the error code invalid-site-private-key, which actually (as we know by now) is a wrong way of really sending a 400 Bad Request. Maybe they should think about implementing this then people would not wonder what's wrong with their keys.
These are the header parameters which are obviously necessary (they imply you're sending a form):
Content-Length which has to be the length of the query string
Content-Type which has to be application/x-www-form-urlencoded
Another thing I learned from the node-recaptcha module is, that one should send the querystring utf8 encoded.
My solution now looks like this, you may use it or built up on it but error handling is not implemented yet. And it's written in CoffeeScript.
http = require 'http'
module.exports.check = (remoteip, challenge, response, callback) ->
privatekey = 'placeyourprivatekeyhere'
request_body = "privatekey=#{privatekey}&remoteip=#{remoteip}&challenge=#{challenge}&response=#{response}"
response_body = ''
options =
host: 'www.google.com'
port: 80
method: 'POST'
path: '/recaptcha/api/verify'
req = http.request options, (res) ->
res.setEncoding 'utf8'
res.on 'data', (chunk) ->
response_body += chunk
res.on 'end', () ->
callback response_body.substring(0,4) == 'true'
req.setHeader 'Content-Length', request_body.length
req.setHeader 'Content-Type', 'application/x-www-form-urlencoded'
req.write request_body, 'utf8'
req.end()
Thank you :)
+1 to #florian for the very helpful answer. For posterity, I thought I'd provide some information about how to verify what your captcha request looks like to help you make sure that the appropriate headers and parameters are being specified.
If you are on a Mac or a Linux machine or have access to one of these locally, you can use the netcat command to setup a quick server. I guess there are netcat windows ports but I have no experience with them.
nc -l 8100
This command creates a TCP socket listening on pot 8100 and will wait for a connection. You then can change the captcha verify URL from http://www.google.com/recaptcha/... in your server code to be http://localhost:8100/. When your code makes the POST to the verify URL you should see your request outputted to the scree by netcat:
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 277
Host: localhost:8100
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1 (java 1.5)
privatekey=XXX&remoteip=127.0.0.1&challenge=03AHJYYY...&response=some+words
Using this, I was able to see that my private-key was corrupted.