Add affiliations with ORCID API

228 views
Skip to first unread message

Bindu Dandamudi

unread,
Mar 14, 2017, 2:23:40 PM3/14/17
to ORCID API Users
We have orcid API 2.0 integrated with java application to create a bio and get the scholarid and update to ur internal datasource.
We are using oauth web service call to get the access token and redirects fine to the sandbox orcid page where we set up the orcid account with password.
We have other step to add affiliations for the user once the accesstoken is generated .

This is the oauth url used where we have scope=/read-limited%20/activities/update

when I use the same access token to send affiliations with this url (curl specified in this "Example to add an affiliation" link - http://members.orcid.org/api/archive/tutorial-add-activities ) and I am getting this error  :- 

https://api.sandbox.orcid.org/v1.2/<scholarid>/affiliations, token: <tokenvalue>

{

  "error" : "invalid_token",

  "error_description" : "Invalid access token: : <tokenvalue>

}


this is the doc provided scope 

/activities/update/affiliationsAdd education or employment items to the ORCID recordXML for Affiliations

Can you please tell me if you know  why  is this failing?


Thanks

Bindu

UFM- Annarbor






Wilmers, Catalina

unread,
Mar 14, 2017, 2:45:31 PM3/14/17
to Bindu Dandamudi, ORCID API Users
Hi Bindu,

The API isn't reading the token you're providing. In the error message returns the token that it is reading and considering invalid after the colon, in your case all it's reading for the token is a colon, " : ". The fact it's trying read the token means that you have the URL and the process to send the token set up correctly (with the authorization type set to "Bearer") and it's just the syntax of providing the token that is wrong (probably just an extra colon).

You can refer to our documentation on reading records in 1.2 for another example of what this call would look like in curl and how the token is provided: http://members.orcid.org/api/archive/tutorial-retrieve-data-orcid-record  However, I'd encourage you to switch your development over to using the 2.0 API as support for 1.2 will be ending this year. The guide for reading a record using 2.0 is at http://members.orcid.org/api/tutorial/read-orcid-records (it's the same call, just a different version and endpoint).

Best,
-Catalina




--
You received this message because you are subscribed to the Google Groups "ORCID API Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orcid-api-users+unsubscribe@googlegroups.com.
To post to this group, send email to orcid-api-users@googlegroups.com.
Visit this group at https://groups.google.com/group/orcid-api-users.
For more options, visit https://groups.google.com/d/optout.

Bindu Dandamudi

unread,
Mar 20, 2017, 3:08:57 PM3/20/17
to ORCID API Users, bdan...@umich.edu
Hi Catalina,
This affiliations xml worked for v1.2 url after fixing the access token .thanks for your correction.

But i am trying to get this xml posted to https://api.sandbox.orcid.org/v2.0_rc2/<orcid>/employment, with valid access token: <token> and getting error-400 , Bad Request.why?

<?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation="http://www.orcid.org/ns/employment ../employment-2.0_rc2.xsd">
<employment:organization> <common:name > University of Michigan</common: name >
<common:address> 
<common: city > Ann Arbor</common: city > 
<common:region > MI </common: region >
<common:country> US </common: country>
</common:address> 
<common:disambiguated - organization>
<common:disambiguated - organization - identifier > 1259 </common:disambiguated - organization - identifier>
<common:disambiguation - source > RINGGOLD </common:disambiguation - source >
</common:disambiguated - organization>
</employment:organization>
</employment:employment>

Thanks
Bindu
To unsubscribe from this group and stop receiving emails from it, send an email to orcid-api-use...@googlegroups.com.
To post to this group, send email to orcid-a...@googlegroups.com.

Wilmers, Catalina

unread,
Mar 20, 2017, 5:04:45 PM3/20/17
to Bindu Dandamudi, ORCID API Users
Hi Bindu,

The XML you've included has issues with extra spaces in a few elements, such as with the element <common:disambiguated - organization - identifier > there should not be spaces around the dashes instead it should be <common:disambiguated-organization-identifier>. I'm not sure if the spacing issue came from the original source, in which case you will need to fix it, or is just a product of pasting the xml into the email. But with the extra spaces removed your XML is valid and can be posted.

If you've fixed the spaces and are still getting an error, please look for an error message with an error-code (a 4 digit number starting with 9) which will provide more specific information about what went wrong. If you're not seeing an error-code in the response, you may want to check your application to make sure it's not truncating error messages.

Best,
-Catalina


To unsubscribe from this group and stop receiving emails from it, send an email to orcid-api-users+unsubscribe@googlegroups.com.
To post to this group, send email to orcid-api-users@googlegroups.com.

Bindu Dandamudi

unread,
Mar 20, 2017, 6:19:13 PM3/20/17
to ORCID API Users

Bindu Dandamudi

unread,
Mar 20, 2017, 6:28:00 PM3/20/17
to ORCID API Users, bdan...@umich.edu
Hi Catalina,
I validated the xml with out spaces and then did post the url but same error code=400 .
i dont see the 4 digit code its always returning Bad request as error message.The app is allowed to display all errors.
Is the url i am posting right? and can you check the logs on sandbox for this request?

<?xml version="1.0" encoding="UTF-8"?><employment:employmentxmlns:employment="http://www.orcid.org/ns/employment" xmlns:common="http://www.orcid.org/ns/commonxmlns:xsi="http://www.w3.org/2001/XMLSchema-instancexsi:schemaLocation="http://www.orcid.org/ns/employment/employment-2.0_rc2.xsd "><employment:organization><common:name>University of Michigan</common:name><common:address><common:city>Ann Arbor</common:city><common:region>MI</common:region><common:country>US</common:country></common:address><common:disambiguated-organization><common:disambiguated-organization-identifier>1259</common:disambiguated-organization-identifier><common:disambiguation-source>RINGGOLD</common:disambiguation-source></common:disambiguated-organization></employment:organization></employment:employment>
TRACE: 2017-03-20 18:16:20,846 main  edu.umich.its.orcid.manager.OrcidManager -DATA: doPostRequest url https://api.sandbox.orcid.org/v2.0_rc2/0000-0002-3588-6521/employment, token: c4bc6fd2-7b4b-4e8d-bf7f-9f69750ca394
TRACE: 2017-03-20 18:16:20,851 main  edu.umich.its.orcid.manager.OrcidManager -DATA: application/vnd.orcid+xml
TRACE: 2017-03-20 18:16:20,852 main  edu.umich.its.orcid.manager.OrcidManager -DATA: Bearer c4bc6fd2-7b4b-4e8d-bf7f-9f69750ca394
TRACE: 2017-03-20 18:16:22,846 main  edu.umich.its.orcid.manager.OrcidManager -DATA: response message- Bad Request,Response{protocol=http/1.1, code=400, message=Bad Request, url=https://api.sandbox.orcid.org/v2.0_rc2/0000-0002-3588-6521/employment},application/vnd.orcid+xml; qs=5;charset=UTF-8,Server
ERROR: 2017-03-20 18:16:22,847 main  edu.umich.its.orcid.manager.OrcidManager -DATA: doPostRequest exception  Unexpected code Response{protocol=http/1.1, code=400, message=Bad Request, url=https://api.sandbox.orcid.org/v2.0_rc2/0000-0002-3588-6521/employment}
java.io.IOException: Unexpected code Response{protocol=http/1.1, code=400, message=Bad Request, url=https://api.sandbox.orcid.org/v2.0_rc2/0000-0002-3588-6521/employment}
at edu.umich.its.orcid.manager.OrcidManager.doPostRequest(OrcidManager.java:112)

Thanks
Bindu

Peters, Robert

unread,
Mar 20, 2017, 6:49:53 PM3/20/17
to Bindu Dandamudi, ORCID API Users
Hi Bindu,
It looks like you are only logging the header status code. There will be more information returned in the body of the response. Including a second more detailed error code.

Cheers,
Rob

Robert Peters
Technology Director at ORCID.org

Cellphone: +1.805.440.9056
Skype: rcpeters
Timezone: PST
Key for OpenPGP email communication:  
https://keys.mailvelope.com/pks/lookup?op=get&search=0x1519F37D99E18378

To unsubscribe from this group and stop receiving emails from it, send an email to orcid-api-users+unsubscribe@googlegroups.com.
To post to this group, send email to orcid-api-users@googlegroups.com.

Bindu Dandamudi

unread,
Mar 20, 2017, 7:46:53 PM3/20/17
to Peters, Robert, ORCID API Users

Here's what i am seeing as response body:-

TRACE: 2017-03-20 19:36:39,787 ajp-nio-127.0.0.1-8009-exec-66  edu.umich.its.orcid.manager.OrcidManager -DATA: body response:<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<error xmlns="http://www.orcid.org/ns/error">

    <response-code>400</response-code>

    <developer-message>400 Bad Request: There is an issue with your data or the API endpoint. 405 Method Not Allowed: Endpoint and method mismatch. 415 Unsupported Media Type: data must be in XML or JSON format.</developer-message>

    <user-message>ORCID could not process the data, because they were invalid.</user-message>

    <error-code>9001</error-code>

    <more-info>https://members.orcid.org/api/resources/troubleshooting</more-info>

</error>


here's the details for post:- 

scope for accesstoken :-  "scope=/read-limited /activities/update /person/update"

(redirect:https://sandbox.orcid.org/oauth/authorize?client_id=APP-8RVUI1BWPUUDCPRS&response_type=code&scope=/read-limited /activities/update /person/update&redirect_uri=https://researchid-dev.dsc.umich.edu/researchId/orcidcallback&given_names=Jeanne&family_names=Horvath&email=jea...@mailinator.com)

header("Content-Type", "application/vnd.orcid+xml")
url=https://api.sandbox.orcid.org/v2.0_rc2/0000-0002-3588-6521/employment
Xml message:-

<?xml version="1.0" encoding="UTF-8"?>

<employment:employment

xmlns:employment="http://www.orcid.org/ns/employment" xmlns:common="http://www.orcid.org/ns/common"

xsi:schemaLocation="http://www.orcid.org/ns/employment ../employment-2.0_rc2.xsd ">

<employment:organization>

<common:name>University of Michigan</common:name>

<common:address>

<common:city>Ann Arbor</common:city>

<common:region>MI</common:region>

<common:country>US</common:country>

</common:address>

<common:disambiguated-organization>

Peters, Robert

unread,
Mar 20, 2017, 8:31:56 PM3/20/17
to Bindu Dandamudi, ORCID API Users
Hi Bindu,
From our side it looks like you are not sending parsable XML.

 type "employment:employmentxmlns" must be followed by either attribute specifications, ">" or "/>".]

Cheers,
Rob

Robert Peters
Technology Director at ORCID.org

Cellphone: +1.805.440.9056
Skype: rcpeters
Timezone: PST
Key for OpenPGP email communication:  
https://keys.mailvelope.com/pks/lookup?op=get&search=0x1519F37D99E18378

Bindu Dandamudi

unread,
Mar 20, 2017, 9:39:57 PM3/20/17
to Peters, Robert, ORCID API Users
yep it worked after correcting the xml .
thanks for your help!!

On Mon, Mar 20, 2017 at 8:31 PM, Peters, Robert <r.pe...@orcid.org> wrote:
Hi Bindu,

From our side it looks like you are not sending parsable XML.

 type "employment:employmentxmlns" must be followed by either attribute specifications, ">" or "/>".]

Cheers,
Rob

Robert Peters
Technology Director at ORCID.org

Cellphone: +1.805.440.9056
Skype: rcpeters
Timezone: PST
Key for OpenPGP email communication:  
https://keys.mailvelope.com/pks/lookup?op=get&search=0x1519F37D99E18378

On Mon, Mar 20, 2017 at 4:46 PM, Bindu Dandamudi <bdan...@umich.edu> wrote:

Here's what i am seeing as response body:-

TRACE: 2017-03-20 19:36:39,787 ajp-nio-127.0.0.1-8009-exec-66  edu.umich.its.orcid.manager.OrcidManager -DATA: body response:<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<error xmlns="http://www.orcid.org/ns/error">

    <response-code>400</response-code>

    <developer-message>400 Bad Request: There is an issue with your data or the API endpoint. 405 Method Not Allowed: Endpoint and method mismatch. 415 Unsupported Media Type: data must be in XML or JSON format.</developer-message>

    <user-message>ORCID could not process the data, because they were invalid.</user-message>

    <error-code>9001</error-code>

    <more-info>https://members.orcid.org/api/resources/troubleshooting</more-info>

</error>


here's the details for post:- 

scope for accesstoken :-  "scope=/read-limited /activities/update /person/update"


--
You received this message because you are subscribed to a topic in the Google Groups "ORCID API Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orcid-api-users/nQDO5i37SCA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orcid-api-users+unsubscribe@googlegroups.com.

Peters, Robert

unread,
Mar 20, 2017, 9:59:41 PM3/20/17
to Bindu Dandamudi, ORCID API Users
Excellent!

Bindu Dandamudi

unread,
Mar 21, 2017, 9:33:54 AM3/21/17
to Peters, Robert, ORCID API Users
I have one more issue to solve with scope.
Currently i have the  scope for accesstoken :-  "scope=/read-limited /activities/update /person/update"
but when i change to  "scope=/read-limited /activities/update /person/update /webhook"
i see the error - 

is there any other configuration that needs to be made for webhook?

Thanks
Bindu

Peters, Robert

unread,
Mar 21, 2017, 11:51:56 AM3/21/17
to Bindu Dandamudi, ORCID API Users
/webhook requires a client_credentials flow seperate from the authorization_code flow. Specific details can be found here https://members.orcid.org/api/tutorial/webhooks and a general OAuth2 explanation here https://alexbilbie.com/guide-to-oauth-2-grants/.

Cheers,
Rob

Robert Peters
Technology Director at ORCID.org

Cellphone: +1.805.440.9056
Skype: rcpeters
Timezone: PST
Key for OpenPGP email communication:  
https://keys.mailvelope.com/pks/lookup?op=get&search=0x1519F37D99E18378

Reply all
Reply to author
Forward
0 new messages