Unable to fetch Education details in linkedin Rest API - java

I am fetching data from given url in JSON format
http://api.linkedin.com/v1/people/~:(id,email-address,first-name,last-name,headline,formatted-name,picture-url,siteStandardProfileRequest,educations:(id,school-name,field-of-study,start-date,end-date,degree,activities,notes),positions:(id,title,summary,start-date,end-date,is-current,company:(id,name,type,size,industry,ticker)))?format=json
Everything works fine, But I am not getting response for education.
Sample Response -
{
"firstName": "FNAME",
"lastName": "LNNAME",
"emailAddress": "S*******#gmail.com",
"formattedName": "FNAME LNNAME",
"pictureUrl": "https:\/\/media.licdn.com\/mpr\/mprx\/0****",
"positions": {
"_total": 1,
"values": [{
"summary": "J2EE DEVELOPER",
**
**
}
}]
}, "id": "5cNYNt0sTY", "headline": "*** Consultancy", "siteStandardProfileRequest": {
"url": "https:\/\/www.linkedin.com\/profile\/view?id=********"
}

Education data is not part of the set of basic profile fields that you have access to. The complete list is available here:
https://developer.linkedin.com/docs/fields/basic-profile

Related

Can there be two ids for an object in json api

I am using a restful webservice that gives response in json api format. There is a relationship attribute that has id and type params. Based on the id reference it displays values in the included attribute. The id is created after the two requests that process as a final output. Till then I save my data in database as one single object. Now when I fetch the data from database using rest webservice the output shows all the attributes except the included. Which I believe is because it isn't able to find the reference so not getting displayed. But in the database all the values are present perfectly. I am not sure whether json api supports multiple ids for relationship attribute or not.
Example:
Request Body:
{
"data": {
"type": "orders",
"attributes": {
"name": "new order",
"updateDate": "",
"register":"yes",
"items":[
{
"description": "newly added item",
"type": "new item",
"amount": [
{
"deliveryfee": "123",
"mrp": "456"
}
]
}
]
}
}
}
Expected Response Body:
{
"data": {
"type": "orders",
"id": "1",
"attributes": {
"name": "new order",
"updateDate": "",
},
"relationships": {
"items": {
"data": [
{
"type": "items",
"id": null
}
]
}
}
},
"included": [
{
"type": "items",
"id": null,
"attributes": {
"type": "new item",
"description": "newly added item",
"amount": [
{
"deliveryfee": "123",
"mrp": "456"
}
]
}
}
]
}
Actual Response Body:
{
"data": {
"type": "orders",
"id": "1",
"attributes": {
"name": "new order",
"updateDate": "",
},
"relationships": {
"items": {
"data": [
{
"type": "items",
"id": null
}
]
}
}
}
}
I'm not fully sure if I understand your question correctly. But let me try to answer.
The combination of a type and id is used in JSON API specification to identify a resource:
Within a given API, each resource object’s type and id pair MUST identify a single, unique resource.
null as used in your example is not a valid value for id:
The values of the id and type members MUST be strings.
The API may combine multiple identifiers used in its internal database to construct the value used for id in a JSON API document as long as it's unique for the given type. This would be a valid id value from JSON API specification point of view as long as it's guaranteed to be unique.
{
"type": "posts":
"id": "post_id:5,locale:en"
}
The API may de-serialize the ID to two different identifiers: A post with the id 5 and a local with the id "en". That would be an internal implementation detail of the API. Consumers should not care if a meaning is encoded within the id value.
The request and response bodies given in your question do not fit together. Both contain a field items. But in the request body the items field is an attribute, while its a relationship in the response.
It seems as if you are trying to create multiple resources at once. This is not support by JSON API specification v1. It is supported in the third release candidate for v1.1 of the specification through the official extension Atomic Operations.

Is it possible to create dynamic pojo class according dynamic json response everytime?

An api provides different result in json everytime I hit. How can I generate a new model class everytime according to json response?
Is it possible to create dynamic pojo class according dynamic json response everytime??
on 1st hit -
{
"Banners": [
{
"banner_id": "30",
"banner_image": ""
}
],
"success": "success",
"message": "Banners"
}
on 2nd hit
{
"Banners": [
{
"banner_desc": "returns between paragraphs",
"banner_type": "regular",
"banner_size": 100,
}
],
"success": "success",
"message": "Banners"
}
on 3rd hit -
{
"user_id": "4",
"name": "",
"email": "k#gmail.com",
"mobile": "",
"image": "",
"success": "success",
"message": "Registered"
}

Dynamic response of Retrofit

My answer Json depends on whether it succeeds or not.
Unsuccessful example:
{
"success": false,
"errors": {
"email": "Could not find email address"
}
}
Successful example:
{
"success": true,
"user": {
"id": 6,
"fname": "XXXXXX",
"lname": "XXXXXX",
"email": "Username#mail.ca",
"roles": [
"Player"
"Coach"
"manager",
"Admin"
]
"date_registered": "2018-03-16T17: 49: 05.000Z"
}
"Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWQiOiJiNjU1MDVkOGJiYzZhMTg1Y2E5MjU5NDlmNTU0OTc0MTgzM2Y2N2NiNjFjYThkMzNkMTUxY2U2MDhjMTBmNTllIiwiaWF0IjoxNTI3MjY3MzEwLCJleHAiOjE1Mjc4NzIxMTB9.p5pTlNjTsr-8N_8B3M5fW3T6PTTrcFo8D77N0WWgA3c"
}
Now, I want to have a POJO for both at the same time with retrofit.
Thank you
Edit : I just solved the problem by changing the form of JSON to :
{
"success": true,
"data": {
"user": {
"id": 6,
"fname": "XXXXXXX",
"lname": "XXXXXXXX",
"email": "Username#mail.ca",
"roles": [
"player",
"coach",
"manager",
"admin"
],
"activation_state": 0,
"date_registered": "2018-03-16T17:49:05.000Z"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaWQiOiI0MTFlZmI5Y2ExYzY1ZWFlYzQ4Yzg1ZjJkYTQwOThmODBjOTk1NWNjNjcyOTNlODI5NmI4N2RjZWY5OTMzYzljIiwiaWF0IjoxNTI4NDI0MDA1LCJleHAiOjE1Mjg0MjQ2MDl9.lTsQ867Lk78RV2ruaQFyxUNfm58bHpfzEsZnvKJQMXQ"
},
"errors": {}
}
Thank you for help
You could simply return a String Retrofit, and then parse it manually.
If not, then you have to create a POJO object that contains all variables from both objects.
And then at runtime you check if "success" is true/false, and then try to access the underlying varaibles.
Copy your json response and past http://pojo.sodhanalibrary.com/
Then submit
You will get multiple pojo class with respect to your response ,

How to document list of objects using Spring Rest Docs

I'm using Spring Rest Docs to document my REST API.
I'm using mockMVC in my integrated tests and I want to document the following JSON response:
GET /api/v1/customers/3b658b39-4264-4995-99d8-90a1672a75a7
{
"id": "3b658b39-4264-4995-99d8-90a1672a75a7",
"name": "Foo",
"nickname": "Bar",
"phones": [
{
"id": "6ca3a963-bacb-4770-a470-5902b4a17b77",
"alias": "Personal Phone 1",
"countryCode": "55",
"areaCode": "34",
"number": "99999-9999"
},
{
"id": "f3a3726b-b5f8-4652-a044-7bf3d95a37de",
"alias": "Personal Phone 2",
"countryCode": "55",
"areaCode": "34",
"number": "88888-8888"
}
]
}
How can I document the list of phones above? You could use the following snippet which uses Spring REST Docs to document this API operation:
this.mockMvc.perform(
get("/api/v1/customers/3b658b39-4264-4995-99d8-90a1672a75a7")
.accept(APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(document("customer").withResponseFields(
fieldWithPath("id").description("Unique identifier"),
fieldWithPath("name").description("Customer full name"),
fieldWithPath("nickname").description("How the customer wants to be called")));
According to this link https://docs.spring.io/spring-restdocs/docs/current/reference/html5/#documenting-your-api-request-response-payloads-fields-json
When documenting nested through array objects, you can use like this:
this.mockMvc.perform(
get("/api/v1/customers/3b658b39-4264-4995-99d8-90a1672a75a7")
.accept(APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(document("customer").withResponseFields(
fieldWithPath("id").description("Unique identifier"),
fieldWithPath("name").description("Customer full name"),
fieldWithPath("nickname").description("How the customer wants to be called"),
fieldWithPath("phones[].id").description("PHONE ID DESCRIPTION"),
fieldWithPath("phones[].alias").description("PHONE ALIAS DESCRIPTION"),
fieldWithPath("phones[].countryCode").description("PHONE COUNTRY CODE DESCRIPTION"),
fieldWithPath("phones[].areaCode").description("PHONE AREA CODE DESCRIPTION")
fieldWithPath("phones[].number").description("PHONE NUMBER DESCRIPTION")
));

Invalid fields for site for Yodlee

I am new to yodlee trying to test the app, I am making a post call with
url -->>https://developer.api.yodlee.com:443/ysl/restserver/v1/providerAccounts?providerId=10588
where 10588 is the provider id for yes bank and sending the data as
{
"field": [
{
"id": "77398",
"value": "user id"
},
{
"id": "77399",
"value": "password"
}
]}
In response I am getting
{ "errorCode": "Y400",
"errorMessage": "Invalid fields for site ...",
"referenceCode": "S1505215393036o4j27f"
}
I believe the user id and password id provided are wrong but yodlee is giving the same id for yes bank, If any one can help regarding the same??
The field Ids doesn't seem to be right. Can you try with the following login form for YES BANK (edit the value field?
Hope this helps.
{
"loginForm": {
"row": [{
"field": [{
"id": 29421,
"value": "username"
}]
},
{
"field": [{
"id": 29420,
"value": "password"
}]
}]
}
}

Categories