1
votes

we are working on sharing with the linkedIn objective C SDK, latest version.

Using this code:

 NSString *url = @"https://api.linkedin.com/v1/people/~/shares";

    NSString *payload = @"{\"visibility\":[{\"code\":\"anyone\"}],\"comment\":\"Check out developer.linkedin.com! http://linkd.in/1FC2PyG\"}";

    if ([LISDKSessionManager hasValidSession]) {
        [[LISDKAPIHelper sharedInstance] postRequest:url stringBody:payload success:^(LISDKAPIResponse *response) {
            // do something with response
            NSLog(@"Success: %@", response.description);
            dispatch_async(dispatch_get_main_queue(), ^{
                _responseLabel.text = response.description;
            });
        } error:^(LISDKAPIError *apiError) {
            // do something with error
            NSLog(@"Error: %@", apiError.description);
             dispatch_async(dispatch_get_main_queue(), ^{
                 _responseLabel.text = apiError.description;
             });
        }];
    }

lifted pretty much from their sample page. (Had to update a bit, the URL on the site was declared with initWithString which is no longer around).

We have requested and receive a valid session and requested the w_share permission as required in the updated spec.

Here is the actual error:

Error Domain=LISDKErrorAPIDomain Code=400 "(null)" UserInfo={LISDKAuthErrorAPIResponse=<LISDKAPIResponse: 0x1288cc100>}

Any hints would be appreciated!

1
I would put a breakpoint and look at the error's userInfo. There's a key there (LISDKAuthErrorAPIResponse) that may have an interesting object with more info. - Lou Franco

1 Answers

1
votes

According to Linked-in's docs and API Console, XML is the default and you need to specify that you want JSON, like this:

   https://api.linkedin.com/v1/people/~/shares?format=json

And possibly with a header (not sure if the LISDKAPIHelper) knows how to do that part.

The documentation is really unclear. I suggest you capture the packets with something like CharlesProxy and see if what is getting sent is what you expect. Alternatively, use your same code, but send XML instead of JSON.