Resolved url not working while posting a share in linkedin page - java

I am trying to post a share with entity location and resolved Url in content entities, Even though i am pointing resolvedUrl to a image, it is not considering that image instead fetching 'og:image' from entity location. I don't see any use of resolvedUrl.
Suggest on how to use resolvedUrl ie. image with custom url.
Body:
{
"owner": "urn:li:organization:xxxxxxx",
"distribution": {
"linkedInDistributionTarget": {}
},
"content": {
"contentEntities": [{
"entityLocation": "https://www.cricbuzz.com/cricket-news/107673/ipl-2019-rishabh-pant-shikhar-dhawan-propel-delhi-capitals-to-the-top-rr-vs-dc-rajasthan-royals",
"thumbnail": [{
"resolvedUrl": "https://www.cricbuzz.com/a/img/v1/595x396/i1/c168531/watson-led-csks-chase-of-176.jpg"
}]
}],
"description": "Description of attachment",
"title": "Title of the attachment"
},
"text": {
"text": "Hii Kaushik from builder"
}
}

Hello I think it might be because of a typo: It should be "thumbnails" instead of "thumbnail", see if it works.
Link: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api#post-shares
{
"owner": "urn:li:organization:xxxxxxx",
"distribution": {
"linkedInDistributionTarget": {}
},
"content": {
"contentEntities": [{
"entityLocation": "https://www.cricbuzz.com/cricket-news/107673/ipl-2019-rishabh-pant-shikhar-dhawan-propel-delhi-capitals-to-the-top-rr-vs-dc-rajasthan-royals",
"thumbnails": [{
"resolvedUrl": "https://www.cricbuzz.com/a/img/v1/595x396/i1/c168531/watson-led-csks-chase-of-176.jpg"
}]
}],
"description": "Description of attachment",
"title": "Title of the attachment"
},
"text": {
"text": "Hii Kaushik from builder"
}
}
Hope this helps.

Related

Slack SDK block builder in spring boot

I'm constructing a message to be sent through my spring boot application.
I was testing out the templates and I have created one where most of the elements are static except a link that needs to be generated by the code and added to the Json.
Currently the Json message looks like this:
{
"blocks": [
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/highpriority.png",
"alt_text": "High Priority"
},
{
"type": "mrkdwn",
"text": "*High Priority*"
}
]
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Hercules Platform Status Response failed Messages*"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Please click the link to download the file*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*<LINK|SOME_LINK>*"
}
}
]
}
I'm not sure how to construct this Json in my spring boot application. Since most of it is static, should I just load this template as a string and append the last link section?
I'm not able to figure out the slack classes in java to build such a message.

Is there an easy way to flatten a json:api response on Android?

I'm trying to flatten the below response without having to parse it into a class. The reason for this is that the server could add or remove fields at anytime so it needs to be dynamic. We also have another service that returns lookup paths that we use to get data out of the flattened response - like "$.detail.att_one" There is a library for iOS that does the exact thing I'm looking for but as far as I can find nothing similar for Android: https://github.com/infinum/Japx
{
"data": [
{
"type": "items",
"id": "14",
"attributes": {
"item_type": "shape_circle",
"code": null,
"size": "70"
},
"relationships": {
"detail": {
"data": {
"type": "circle",
"id": "90"
}
},
"metadata": {
"data": "metadata"
}
},
"links": {
"self": "http://url/item/14"
}
}
],
"included": [
{
"type": "circle",
"id": "90",
"attributes": {
"att_one": 4,
"att_two": "11111111111",
"att_three": "Bob"
}
}
]}
The result I'm looking for:
{
"data": [
{
"id": "14",
"type": "items",
"item_type": "shape_circle",
"code": null,
"size": "70",
"metadata": {
"data": "metadata"
},
"detail": {
"type": "circle",
"id": "90",
"att_one": 4,
"att_two": "11111111111",
"att_three": "Bob"
},
"links": {
"self": "http://url/item/14"
}
}
]}
There is a nice JSONAPI library that does the thing, but you have to define resource classes for it.
Check out jasminb/jsonapi-converter
It recursively flattens all the included relationships and handles inheritance.

ElasticSearch hits have no fields

I am having a problem where when I run a search on elastic using the java api I get back results... but when I try and extract values from the results there are no fields.
ElasticSearch v5.3.1
Elastic API: org.elasticsearch.client:transport v5.3.0
My code:
SearchRequestBuilder srb = client.prepareSearch("documents").setTypes("documents").setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(qb).setFrom(0).setSize((10)).setExplain(false);
srb.addDocValueField("title.raw");
SearchResponse response = srb.get();
response.getHits().forEach(new Consumer<SearchHit>() {
#Override
public void accept(SearchHit hit) {
System.out.println(hit);
Map<String, SearchHitField> fields = hit.getFields();
Object obj = fields.get("title.raw").getValue();
}
});
When the forEach runs the obj is always coming back null. Fields has an item in it with the key of title.raw and it has a SearchHitField.
Fields is only used when you are trying to obtain stored fields. By default you should obtain fields using the source. With the following code samples I'll try to explain it.
PUT documents
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
"document": {
"properties": {
"title": {
"type": "text",
"store": true
},
"description": {
"type": "text"
}
}
}
}
}
PUT documents/document/_bulk
{"index": {}}
{"title": "help me", "description": "description of help me"}
{"index": {}}
{"title": "help me two", "description": "another description of help me"}
GET documents/_search
{
"query": {
"match": {
"title": "help"
}
},
"stored_fields": ["title"],
"_source": {
"includes": ["description"]
}
}
Next the response, notice the difference between the stored field Title and the normal field description.
{
"_index": "documents",
"_type": "document",
"_id": "AVuciB12YLj8D0X3N5We",
"_score": 0.14638957,
"_source": {
"description": "another description of help me"
},
"fields": {
"title": [
"help me two"
]
}
}

how to send HTTP Post request using jersey with a complex parameter

I need to send a HTTP Post to a REST API with the following complex type as parameters. I looked at the documentation of jersey and it helps only to send a key value pair. How can i send a HTTP Post request with the below parameters using jersey.
{
"key": "example key",
"message": {
"html": "<p>Example HTML content</p>",
"text": "Example text content",
"subject": "example subject",
"from_email": "message.from_email#example.com",
"from_name": "Example Name",
"to": [
{
"email": "recipient.email#example.com",
"name": "Recipient Name"
}
],
"headers": {
"Reply-To": "message.reply#example.com"
},
"important": false,
"track_opens": null,
"track_clicks": null,
"auto_text": null,
"auto_html": null,
"inline_css": null,
"url_strip_qs": null,
"preserve_recipients": null,
"view_content_link": null,
"bcc_address": "message.bcc_address#example.com",
"tracking_domain": null,
"signing_domain": null,
"return_path_domain": null,
"merge": true,
"global_merge_vars": [
{
"name": "merge1",
"content": "merge1 content"
}
],
"merge_vars": [
{
"rcpt": "recipient.email#example.com",
"vars": [
{
"name": "merge2",
"content": "merge2 content"
}
]
}
],
"tags": [
"password-resets"
],
"subaccount": "customer-123",
"google_analytics_domains": [
"example.com"
],
"google_analytics_campaign": "message.from_email#example.com",
"metadata": {
"website": "www.example.com"
},
"recipient_metadata": [
{
"rcpt": "recipient.email#example.com",
"values": {
"user_id": 123456
}
}
],
"attachments": [
{
"type": "text/plain",
"name": "myfile.txt",
"content": "ZXhhbXBsZSBmaWxl"
}
],
"images": [
{
"type": "image/png",
"name": "IMAGECID",
"content": "ZXhhbXBsZSBmaWxl"
}
]
},
"async": false,
"ip_pool": "Main Pool",
"send_at": "example send_at"
}
I looked at the other questions of sending HTTP Post using Jersey and all I could find was a way to only send a key\value pairs as parameters and not complex string types like above.
You should look at JAXB, it allows you to "automatically" build "complex parameters" out of "objects". Basically the procedure would be to define a class that represents the data structure you present as request message the REST API resource accepts, then populate it with the data your want to POST and send it. In this question you can find more details on how to exactly do that: Can jersey clients POST a JAXB object to the server using JSON?

IBM Jazz Team Server: How to retrieve changes from a change set?

I use the REST API to retrieve the change set from a project. I get for example the following response:
{
"changes": [
{
"kind": 2,
"item": {
"uri": "itemOid\/com.ibm.team.filesystem.FileItem\/_2ItWACJKEeGAaaEbbqTtgw",
"itemId": "_2ItWACJKEeGAaaEbbqTtgw",
"com.ibm.team.repository.typeName": "com.ibm.team.filesystem.FileItem"
},
"before": "_Rx7-BCJaEeG25dOp_iUerQ",
"after": "_Ngn9BCJeEeG25dOp_iUerQ",
"internalId": "_NhCzwCJeEeG25dOp_iUerQ"
},
{
"kind": 1,
"item": {
"uri": "itemOid\/com.ibm.team.filesystem.FileItem\/_GWB-kCJeEeGAaaEbbqTtgw",
"itemId": "_GWB-kCJeEeGAaaEbbqTtgw",
"com.ibm.team.repository.typeName": "com.ibm.team.filesystem.FileItem"
},
"before": null,
"after": "_Ngn9CyJeEeG25dOp_iUerQ",
"internalId": "_NhCzwSJeEeG25dOp_iUerQ"
}
],
"comment": "",
"lastUpdatedDate": "2011-12-09T12:06:52.266Z",
"active": false,
"owner": {
"uri": "itemOid\/com.ibm.team.repository.Contributor\/_hhbosPC1EeCsJbI2ZgPDog",
"itemId": "_hhbosPC1EeCsJbI2ZgPDog",
"com.ibm.team.repository.typeName": "com.ibm.team.repository.Contributor"
},
"com.ibm.team.repository.typeName": "com.ibm.team.scm.ChangeSet",
"stateId": "_R7C54SJeEeG25dOp_iUerQ",
"component": {
"uri": "itemOid\/com.ibm.team.scm.Component\/_auolkPC9EeCek69P-ztT9w",
"itemId": "_auolkPC9EeCek69P-ztT9w",
"com.ibm.team.repository.typeName": "com.ibm.team.scm.Component"
},
"contextId": "_Dp6kMdwTEd2jUupDpQV1Rw",
"predecessor": "_NhCzwiJeEeG25dOp_iUerQ",
"modified": "2011-12-09T12:06:52.288Z",
"mergePredecessor": null,
"uri": "itemOid\/com.ibm.team.scm.ChangeSet\/_Nb_UoCJeEeG25dOp_iUerQ",
"itemId": "_Nb_UoCJeEeG25dOp_iUerQ",
"properties": [
],
"modifiedBy": {
"uri": "itemOid\/com.ibm.team.repository.Contributor\/_hhbosPC1EeCsJbI2ZgPDog",
"itemId": "_hhbosPC1EeCsJbI2ZgPDog",
"com.ibm.team.repository.typeName": "com.ibm.team.repository.Contributor"
},
"xComponentLink": null,
"etag": "_R7C54SJeEeG25dOp_iUerQ"
}
Now I want to find the source code files as well as the changes. But how can I do it? When i try to send a HTTP Get to the uri in the list changes, then I get a Bad Request 400 error. What can I do?
The rest call you are calling is probably not API - use it at your own risks. Format will most likely change in future.
I assume you found about that rest call while using the Source Control Web UI. You can go to the history view, look at a change, go to an after or before state. This takes you to the state view. Right click on the download link. This is one way to get the URI needed to fetch the content associated to a particular state referenced in a change in a change set. This should get you on the way.

Categories

Resources