Announcement Announcement Module
Collapse
No announcement yet.
spring-social-linkedin - createPost() ..doesn't return post id? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring-social-linkedin - createPost() ..doesn't return post id?

    Hi,

    I was browsing through the API and I saw that on groupOperation, the createPost method returns void... thus not allowing me to perform any other operation on that post.. (like flagAsJob ) (cause i have no idea what's the created id..)

    is the void on purpose? (part of LK api?)

    anyway I can post something and get the ID back?


    Cheers,
    Yoni

  • #2
    Although I didn't write the code for that method (it was contributed by a community member), I've played around with it and from what I can tell, the LinkedIn API does not return anything when posting a message to a group.

    Internally, the LinkedInTemplate uses a RestTemplate and I altered the call for createPost() to return the response as a String and then log it. When testing it against LinkedIn's API, the message was, in fact, posted to the group, but the RestTemplate gave back the response as null. This is at least consistent with the API documentation which doesn't describe any form of return message structure.

    That said, further investigation reveals that the API does return the location (e.g., URI) of the newly created Post in the header of the response. Thus, I was able to change createPost() to return a URI containing the location of the Post. That URI has as part of its path, the ID of the Post. For example, I created a Post and got the following URI:

    http://api.linkedin.com/v1/posts/g-4402609-S-108273072

    You could extract that last portion of the URI and use it as the ID of the Post. I might consider adding some convenience to the LinkedIn API binding to extract that for you...but I want to think on it some more before I do. In the meantime, the new createPost() method that returns a URI will find its way into a build snapshot momentarily.

    Comment


    • #3
      Thanks.

      I'll have a look @ the snapshot.
      Is it safe to use it or it broke some API's?

      BTW - Only god knows why LinkedIn designed their API's in such a way...

      Comment


      • #4
        It's safe to use. The previous implementation of createPost() returned void, so you aren't already assigning its return value to anything. If anyone continues to not assign it to anything then no problems...but now you have the option of assigning it to a java.net.URI if you're interested.

        Snapshots are generally safe to use, although there are no guarantees. This is especially true of snapshots that are pre-1.0 (as is the case with LinkedIn), as we reserve the right to change our minds. But I avoid making breaking changes unless I've thought it through and can think of a darn good reason to do so.

        And, BTW - Only god knows why {insert any public API provider here} designed their API's in such a way...

        Comment


        • #5
          Thanks!
          I'll give it a try and keep you update on the results.

          As for public API's, I agree. It goes without saying...

          Comment

          Working...
          X