cancel
Showing results for 
Search instead for 
Did you mean: 

(ask) CPI Integration SFTP to Linkedin

former_member76287
Participant
0 Kudos

Dear Expert,

need your advise

i have error regarding integration from SFTP into Linkedin

Error Details org.apache.camel.component.ahc.AhcOperationFailedException: HTTP operation failed invoking https://api.linkedin.com/media/upload?media_type=enterprise_csv_upload&auto_notify=true with statusCode: 401is someone can help me to fix this error ?here is my iflow

Accepted Solutions (1)

Accepted Solutions (1)

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Achmad,

HTTP Status 201 conveys something like below.

"The request has been fulfilled and has resulted in one or more new resources being created.The primary resource created by the request is identified by either a Location header field in the response or, if no Location field is received, by the effective request URI.

The 201 response payload typically describes and links to the resource(s) created. See Section 7.2 of RFC7231 for a discussion of the meaning and purpose of validator header fields, such as ETag and Last-Modified, in a 201 response."

Hopefully your data is successfully updated in LinkedIn and may be you can do a search for the records you have inserted.May be posting a query in LinkenIn forum would help you to understand more on LinkedIn API responses.

Regards,

Sriprasad Shivaram Bhat

Answers (10)

Answers (10)

former_member76287
Participant
0 Kudos

Dear Everyone,

is there someone can help me regarding
my POST data into linkedin, why my header changed from primary_email_address into ?primary_email_address

--CPI
Content-Disposition:form-data;name="files"; filename="customizedCsvDownload.csv"
Content-Type:text/csv

primary_email_address,preferred_first_name,preferred_last_name,work_title,Default_license_learning_proEnglish_status
test5@yahoo.com,test,5,HR,active
--CPI--

into

--CPI
Content-Disposition:form-data;name="files"; filename="customizedCsvDownload.csv"
Content-Type:text/csv

?primary_email_address,preferred_first_name,preferred_last_name,work_title,Default_license_learning_proEnglish_status
test5@yahoo.com,test,5,HR,active
--CPI--
former_member76287
Participant
0 Kudos

Dear sriprasadshivaramabhat

i have question,

regarding my POST data into linkedin, why my header changed from primary_email_address into ?primary_email_address

--CPI
Content-Disposition: form-data; name="files"; filename="customizedCsvDownload.csv"
Content-Type: text/csv

primary_email_address,preferred_first_name,preferred_last_name,work_title,Default_license_learning_proEnglish_status
test5@yahoo.com,test,5,HR,active
--CPI--

into

--CPI
Content-Disposition: form-data; name="files"; filename="customizedCsvDownload.csv"
Content-Type: text/csv

?primary_email_address,preferred_first_name,preferred_last_name,work_title,Default_license_learning_proEnglish_status
test5@yahoo.com,test,5,HR,active
--CPI--

any advise ?

thank you

former_member76287
Participant
0 Kudos

Dear sriprasadshivaramabhat

here is the log

messagelog-sftp-linkedin-copy3-attachment-1-untitl.txt

i'm trying to do by postman and it has similar respond.

{"location":"urn:li:media:AgAAAG4BAfQMGqBzFlThAAABb6yLvknWZNVnip9tzxkYnJm6Sxi4ybiZYJmKTdjzkASVnncVFN82IqZ3FYDGnlJGabIvk_zKhguyi38kIWu-F3esyi3_brY4Vh9rutb1KK3FW7zPCEAx4ioexuguXNIqrAAAAQpcAQAAAW-si75JnS27oDhjTokyKDhP9Wqw_IWqUSI9zqGxY_n4ArY-Gpo5wDFCSBADqmqqJMUCuYx8JS1ZB4pMOwJlcKCEp6ORzVfMTTdZCg1DkSkP-3Gi21i80twBWcjTGhlJcW5BIlBNsRs3cH4ug_AyF0MWMZYRLDnRBaUgpFJMW4Dzo5OCLhKqwxSvGNleXnk6K-hrPP8vIP3LG5Li2K3WZoXq9Vv4pOSy4e0nmH_AgMU37VtEDQY9bol1OW6EJAGkqCt0JBYNUFpfmfcXM8YcRORs2kaZNADGNr18Xdz16xsdlmmP6rnXnFPOuC5WIbr8fI-Ldlr0f1hRkeEEC7CaBlqwGHpUmgAB"}

now i'm confuse ...

here is my file

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Achmad,

As per my understanding whenever you update data to LinkedIn you will get response.Have you checked the response what you are getting back whether update is successful or failed.You can enable the trace ( Go to Operations View-->Manage Integration Content-->Select your iflow and navigate to Log Configurations-->Set Log Level to Trace ) to find out the response you are getting or add below script which creates attachment to MPL ( visible in Message Monitoring page ) to find out what happened at LinkedIn side.

Its very difficult to debug from SAP CPI as you have mentioned message is successful from SAP Side( please try to get the response from LinkedIn to find out the issue ).

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
	def body = message.getBody(java.lang.String) as String;
	def messageLog = messageLogFactory.getMessageLog(message);
	messageLog.addAttachmentAsString("ResponseFromLinkedIn:", body, "text/xml");		
	
	return message;
}

Regards,

Sriprasad Shivaram Bhat

former_member76287
Participant
0 Kudos

Dear sriprasadshivaramabhat


i have updated based on your recomendation

the flow is completed, but when i check in linkedin users

the user didnt have license

any advise ?

here is my updated design

here is trace log

messagelog-sftp-linkedin-copy2.txt

check on payload like this

--CPI
Content-Disposition: form-data; name="files"; filename="customizedCsvDownload.csv"
Content-Type: text/csv

primary_email_address,preferred_first_name,preferred_last_name,work_title,Default_license_learning_proEnglish_status
test5@yahoo.com,test,5,HR,active
--CPI--

when POST to linkedin

--CPI
Content-Disposition: form-data; name="files"; filename="customizedCsvDownload.csv"
Content-Type: text/csv

?primary_email_address,preferred_first_name,preferred_last_name,work_title,Default_license_learning_proEnglish_status
test5@yahoo.com,test,5,HR,active
--CPI--

seems like our body is changed

i dont know where is ?primary_email_address

Please help

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Achmed,

You need to convert the incoming csv to have multipart format and then it should work.

Refer below blog and there is script written to form multipart format.

https://blogs.sap.com/2018/09/25/part-6-simplify-integration-of-data-from-sap-to-third-party-applica...

https://blogs.sap.com/2018/02/09/the-marriage-between-form-data-and-sap-cloud-platform-integration/

Regards,

Sriprasad Shivaram Bhat

former_member76287
Participant
0 Kudos

Dear sriprasadshivaramabhat

i have changed and the error became
org.apache.camel.component.ahc.AhcOperationFailedException: HTTP operation failed invoking https://api.linkedin.com/media/upload?media_type=enterprise_csv_upload&auto_notify=true with statusCode: 400

if i'm trying to do this command by manual it works

curl -H 'Content-Type: multipart/form-data' -H 'Authorization: Bearer <OAUTH_TOKEN>' --form 'file=@</path/to/upload.csv>;type=text/csv' -X POST "https://api.linkedin.com/media/upload?media_type=enterprise_csv_upload"
Can you advise me ?

thank you

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Achmad,

I think in content modifier you can try adding prefix key with Bearer.

Regards,

Sriprasad Shivaram Bhat

former_member76287
Participant
0 Kudos

Hi t.vanrooijen

is there any advise how can i do ?

i have cross check with linkedin and they said the token is right

tomvanrooijen
Participant
0 Kudos

401 means authentication failure, so concentrate on that. Your linkedin credentials may be at fault.