Search code examples
javascriptajaxjquerylinkedin-api

linkedin Api : how can I use a value stored in a variable to post network update


I have a string variable ... I want the value stored in this variable to be posted as network update in LinkedIn .....

can someone guide me how can I modify the code below to achieve this functionality..

updateURL = "/people/~/person-activities"
IN.API.Raw(updateURL)
  .method("POST")
  .body('{"contentType":"linkedin-html","body":"my nw update"}')
  .result(function(result) {
      alert ("Updated");
  })
  .error( function(error) { console.log(error); })

Right now it posts "my new update".


Solution

  • JSON.Stringify all you need to place here as linkedin api supports json, so u just need to convert your variable into json string.

    IN.API.Raw("/people/~/current-status") // Update (PUT) the status
    .method("PUT")
    .body(JSON.stringify(urvariablehere))
    .result( function(result) { document.getElementById("statusDiv").innerHTML = "Status updated"; } )
    .error(  function(error)  { /* do nothing */ } );