I had integrated the latest sdks of Linkedin for sharing the contents. As it is worked before but now its gives the errors. Please find the below error message.
Error Domain=LISDKErrorAPIDomain Code=400 "(null)" UserInfo={LISDKAuthErrorAPIResponse=}
Please find the below code which I am using in the application for sharing the contents.
- (IBAction)postOnLinkedin:(id)sender {
if ([LISDKSessionManager hasValidSession]) {
[self postOnLinedln];
}
else {
[LISDKSessionManager createSessionWithAuth:[NSArray
arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION,
LISDK_EMAILADDRESS_PERMISSION, LISDK_W_SHARE_PERMISSION, nil]
state:@"some state" showGoToAppStoreDialog:YES
successBlock:^(NSString *returnState) {
[self postOnLinedln];
}
errorBlock:^(NSError *error) {
[self showAlert:error.localizedDescription];
}
];
}
}
- (void)postOnLinedln {
NSString *url = @"https://api.linkedin.com/v1/people/~/shares";
NSString *payload = [NSString stringWithFormat:@"{\"comment\":\"Hello\","
"\"content\":{ \"title\":\"Title\","
"\"description\":\"%@\","
"\"submitted-url\":\"\","
"\"submitted-image-url\":\"\"},"
"\"visibility\":{ \"code\":\"anyone\"}}", self.description];
if ([LISDKSessionManager hasValidSession]) {
[[LISDKAPIHelper sharedInstance] postRequest:url stringBody:payload
success:^(LISDKAPIResponse *response) {
// do something with response
dispatch_sync(dispatch_get_main_queue(),^{
[self showAlert:@"Posted successfully"];
});
}
error:^(LISDKAPIError *apiError) {
// do something with error
dispatch_sync(dispatch_get_main_queue(),^{
[self showAlert:apiError.description];
});
}];
}
else {
[self showAlert:@"No Valid session Linkdln"];
}
}
As I have also gone through the developer portal of LinkedIn for resolving the issue but not getting any help on that.
Actually you do not passed the characters in the description field which is more than 256 which mentioned in the linkedin guideline.
For more information please find the below screenshot: