How to convert Json (from JIRA's webhook) to Custom Java object - json

I have some Java REST APIs which will be invoked via JIRA Webhook configuration.
Now, when JIRA webhook is invoking REST API, there are large no. of custom fields (like customfield_17270) which contain useful data.
For example, I have configured "Create Issue" event in JIRA webhook i.e. whenever any issue will be created in JIRA, my REST API will be invoked. While creating issue in JIRA, for example, there is a field named "Issue Title" whose value is "XXX". In JSON payload, ideally key-value pair should be "Issue Title":"XXX" but it is like "Custom_Field109":"XXX".
Now the problem is how to map this dynamic JSON to Java Object.
Is there anyone who has faced similar problem.

Each time you receive the webhook, you'll need to map each custom id (e.g. customfield_10070) to it's name by querying the field JIRA REST API at GET: /rest/api/2/field
...which will give you something like this:
[
{
"id": "issuetype",
"name": "Issue Type",
"custom": false,
"orderable": true,
"navigable": true,
"searchable": true,
"clauseNames": [
"issuetype",
"type"
],
"schema": {
"type": "issuetype",
"system": "issuetype"
}
},
{
"id": "customfield_10070",
"name": "FAQ Necessary?",
"custom": true,
"orderable": true,
"navigable": true,
"searchable": true,
"clauseNames": [
"cf[10070]",
"FAQ Necessary?"
],
"schema": {
"type": "string",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons",
"customId": 10070
}
},
...
]
You should then easily be able to iterate over the fields from the webhook JSON and map the custom field id to its display name.

I was able to discuss this issue with JIRA internal team and they provided me custom fields mapping to their JIRA display name.
Basically, when we receive Json keys like Custom_field109 then it means 109 is internal database id for this attribute.
Now, based on given mapping, I parsed JSON to get required keys and then through Jackson library, I was able to map JSOn to Java.

Related

creating a report/catalog item using REST API in SSRS 2017

I am trying to create a report/catalog item using the SSRS REST APIs documented here.
I can successfully create folders and resources using the json:
{
"Name": "Test_Report",
"Description": "",
"Path": "MyFolder/Test_Report",
"Type": "ReportModel",
"Hidden": false,
"ModifiedBy": "User",
"CreatedBy": "User",
"ParentFolderId": null,
"IsFavorite": false,
"ContentType": null,
"Content": "" }
However when creating a report or catalog item, I am getting HTTP 500 or 400 errors like: this
My questions are:
what should be the values for "ContentType" and "Content"
In the server stub generated from the swaggerhub, the description for "Content" is:
A string value that contains binary encoding by base64url encoding rules
what does this mean exactly? and what should be the "ContentType" for this?
Is there any other way to create a report or catalog item using the REST API?
Turns out it the issue is with Newtonsoft.Json.JsonConvert.SerializeObject() and HttpClient.PostAsync() methods.
Sending a request with Restsharp does the job

Is there any data returned from the Forge Data Management Search api to indicate a model is deleted?

When using GET projects/:project_id/folders/:folder_id/search, Forge Data Management API on a model with a deleted last version, is there a any information in the "attributes" or other returned data that indicates the file is deleted?
Currently, a second call to GET projects/:project_id/items/:item_id/versions is used to determine if the latest version is deleted (below) but it would be preferable to not call another request to get this information.
Returned JSON from /versions (with some data removed):
"data": [{
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.w0cwXPUwQziKIHtKBtYRaA?version=3",
"attributes": {
"versionNumber": 3,
"extension": {
"type": "versions:autodesk.core:Deleted",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.core:Deleted-1.0"
},
"data": {
"originalName": "**.rvt"
}
}
}]
The json attribute.hidden = true seems to indicate deleted. This can be accessed via the filter[hidden] = true. I'm closing this as the correct answer.

vimeo-api remove part of JSON response

Is possible (sending a specific parameter in request) remove part of JSON response?
Like the Youtube API v3 part parameter: The part parameter specifies a comma-separated list of one or more video resource properties that the API response will include.
Thanks,
The Vimeo API supports a fields whitelist, so instead of saying "exclude this", you include a list of everything you want.
There is more documentation here: https://developer.vimeo.com/api/spec#json-filter
But the idea is you add the parameter fields, and a comma separated list of fields. Nested data should be broken up with periods. So the following representation
{
"name": "dashron",
"websites": [{
"name": "facebook"
},{
"name": "twitter"
}],
"metadata": {
"albums": {
"uri": "...",
"options": "...",
"total": "..."
}
}
Is the result of an API call with the following fields parameter
fields=name,websites.name,metadata.albums

How to get the full pointer data in Parse.com

i'm making a new application using Parse.com as a backend, i'm trying to make less requests to the Parse, I have a class which is pointing to another object of another class.
Class1(things):
ObjectID Name Category(pointer)
JDFHSJFxv Apple QSGKqf343
Class2(Categories):
ObjectID Name Number Image
QSGKqf343 Fruits 45 http://myserver.com/fruits.jpeg
when i'm trying to retreive data for my first class things using REST API i'm getting this json object :
{
"results": [
{
"Name": "Apple",
"createdAt": "2015-07-12T02:50:20.291Z",
"objectId": "JDFHSJFxv",
"category": {
"__type": "Pointer",
"className": "Teams",
"objectId": "QSGKqf343"
},
"updatedAt": "2015-07-12T02:55:33.696Z"
}
]
}
the json doesn't contains all the data included in the object i'm pointing to, I will have to make another request to get all the data of that object,
is There any way to fix that
You need to tell Parse to return the related object in your query, via the include key.
e.g., add the following to your CURL --data-urlencode 'include=category'

Parse pointer in JSON file are blank after import

first time poster here.
I uploaded a JSON file to Parse, one of my "columns" is an array of Pointers, but it's not pointing to the objectId field, like so:
{ "Tags": [
{
"__type": "Pointer",
"className": "TAGS_Categories",
"TAGS": "Tag1"
},
{
"__type": "Pointer",
"className": "TAGS_Categories",
"TAGS": "Tag2"
},
{
"__type": "Pointer",
"className": "TAGS_Categories",
"TAGS": "Tag3"
}
]
}
But after I imported the file to Parse, this is what appears under "Tags":
[{},{},{}]
My questions are:
1) is the data somehow hidden and it's just not appearing on the website's spreadsheet?
2) if it's truly gone, what would the best way to fix my JSON file so that it will appear?
Help :-(
When uploading content you need to follow the required data format. Pointers are connected by a combination of the class name and the object id for the item to connect to. Without the object id the item in the data store can't be found (a name lookup will not be performed).
You need to update your JSON payload to include the object ids.
Each item must have the fields:
{"__type":"Pointer","className":"XXXX","objectId":"YYYYYYYYYY"}