DCH DCH - 1 year ago 125
Javascript Question

LinkedIn Share API returning "Bad Request" error

I'm trying to implement the LinkedIn share API an I can't figure this one out, since the reply doesn't really tell what's going on.

I've implemented this simple code on my website

<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: xxx
authorize: true
lang: de_DE

<script type="text/javascript">
// Handle the successful return from the API call
function onSuccess(data) {

// Handle an error response from the API call
function onError(error) {

function shareToLinkedIn(){
var payload = {
"content": {
"title": "Test title",
"description": "test description",
"submitted-url": "http://www.someurl.com",
"submitted-image-url": "http://someurl.com/somepic.png"
"visibility": {
"code": "connections-only"


I'm calling this function via an onClick-event:

<a id="linkedin" href="#"onClick="shareToLinkedIn()"><i class="fa fa-linkedin-square" aria-hidden="true"></i> LinkedIn Test</a></li>

But all I'm getting is the following response:
Object {errorCode: 0, message: "Invalid arguments: {S_400_BAD_REQUEST=Bad request}", requestId: "4JVTZJFVF1", status: 400, timestamp: 1467381898243}

Answer Source

Answer to this: You need to implement a login button on your site as well, it's not enough just to be logged in to the LinkedIn-Site. So, on the site where you "share app" is implemented, add:

<script type="in/Login"></script>

After that, click the button, authorize the app and it should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download