Hello,
I'm having a hard time mapping the works Schema to JSON values using Java RestClient.
Is there a place where I can find POJOs that maps ORCID info to JSON via JAVA and rest client? Or are there any recent JAVA ORCID repos anywhere?
These are the steps that I have done so far.
1. Created a sandbox account for public api.
2. Added information to my orcid record: Employment, Education, Works, etc..
3. Grabbed the pub sandbox url and plugged it into my properties/yml file.
4. Tested GET commands in Swagger.
I would like to just test first before OAuth integration.
one first and I get back JSON data.
I would assume it would be straight forward getting items if I map it correctly in my pojos using rest template like this.
WorksInput worksResults = restTemplate.getForObject(orcidPublicApiUrlWorks, WorksInput.class);
I have approximately 30 pojos that will be used for works...see below
WorksInput pojo below:
@JsonProperty("last-modified-date")
private LastModifiedDate lastModifiedDate;
private List<Group> group;
private String path;
LastModifiedDate Pojo Below:
public class LastModifiedDate {
private String value;
public String getValue(){
return value;
}
public void setValue(String input){
this.value = input;
}
Group Pojo below:
public class Group {
@JsonProperty("last-modified-date")
private LastModifiedDate lastModifiedDate;
@JsonProperty("external-ids")
private ExternalIds externalIds;
@JsonProperty("work-summary")
private List<WorkSummary> workSummary = new ArrayList<WorkSummary>();
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
etc..etc...etc
The first error message I received was this...() Then I started adding a constructor to group with a json annotation. Didn't work.
MismatchedInputException: Cannot construct instance of `org.nrt.orcid.pojo.Group` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('2021-07-05T13:29:05.801Z')
So I went back to last modified date and got this error so I added this @JsonProperty("last-modified-date") because java doesn't accept (-) dashes in strings
and I have to match the exact name of the data element coming back.
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `org.nrt.orcid.pojo.LastModifiedDate` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('2021-07-05T13:29:05.801Z')
This error caught my eye.
RestClientException: Error while extracting response for type [class org.nrt.orcid.pojo.WorksInput] and content type [application/xml;charset=UTF-8];
I made some changes and now im here after adding HttpMessageConverter code.
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
Thank you for any assistance you may provide.