Translate or dissect API format

Any help is appreciate.

We have a client that would like to create issue via API. Their API format is in JSON but inflexible in away that they have their own format of data.

They expect JIRA API that complies and dissect it internally.

Is this possible?

i.e. below the sample of format of the API being sent

{
“data”: {
“type”: “incidents”,
“id”: “Track incident identifier”,
“attributes”: {
“incident”: {
“incidentType”: “incident type”,
“incidentState”: “incident state”,
“incidentUrgency”: “‘low’, ‘medium’, ‘high’”,
“incidentImpact”: “‘low’, 'medium, ‘high’”,
“incidentSourceTimestamp”: “2020-01-01T00:00:00Z”,
“incidentReceivedTimestamp”: “2020-01-01T00:00:00Z”
},
“incidentEvents”: {
“2020-01-01T00:00:00Z”: “event info”,
… additional event history …
},
“incidentAlerts”: [
{
“alert”: {
“alertType”: “alert type”,
“alertState”: “‘alerted’, ‘OK’”,
“alertRaisedTimestamp”: “2020-01-01T00:00:00Z”,
“alertReportedTimestamp”: “2020-01-01T00:00:00Z”,
“alertStateChangedTimestamp”:
“2020-01-01T00:00:00Z”
},
“installationPoint”: {
“installationType”: “type of installation point”,
“serviceDeskId”: “scheme specific identification”,
“mobileLocation”: {
VTK-00002
Revision 1.0
External Service Desk API
Track
Page 13 of 22
“vehicleType”: “‘bus’ or ‘tram’”
“vehicleId”: “vehicle identifier”,
“vehicleSection”: “vehicle section”,
“polePosition”: “numeric or other pole
identification”
},
“railLocation”: {
“operator”: “operator of the location”,
“line”: “line or route identifier”,
“station”: “station identifier”,
“array”: “gate array identifier”,
“position”: “gate position identifier
within array”
},
“otherLocation”: {
… reserved for future use…
},
}
“installedDevice”: {
“electronicSerialNumber”: “electrionic serial
number”,
“deviceType”: “type of device”,
“firmware”: “firmware version identifier”,
“software”: “software version identifier”,
“configuration”: {
“static”: “static CD version identifier”,
“dynamic”: “dynamic CD version identifier”
“emv”: “EMV specific version identifier”
}
},
{ … repeated for additional alerts for this incident … }
]
},
“links”: {
“self”: “https://URL for this Incident on service”,
“remote”: “https://URL for this Incident at Service Desk”
}
}
}

One way you could achieve your goal is by creating a microservice, of which you can expose an API endpoint to your client. Once the client sends the above data to your API endpoint, you can parse it internally in a way JSD’s create request API expects and make that API call.

Since there are many ‘keys’ in the above data, which are not accepted by create request API by default, you have to do multiple steps to set this up (Please note this will take effort but it works):

  1. You will have to add custom fields to issues, which can be then added to a request type. For example, create 2 custom field ‘Incident type’ and ‘Incident state’. And then add those fields to particular request type, say ‘Incident’. To learn more about how to add fields to a service request form, please follow this link.

  2. Then note down the fieldId of the above fields from GET request type fields API. And then make the call to create request API as usual and it should work. Here is an example:

curl --location --request POST 'https://anmol2.atlassian.net/rest/servicedeskapi/request' \
--header 'X-ExperimentalApi: opt-in' \
--data-raw '{
  "requestParticipants": [
    "...."
  ],
  "serviceDeskId": "1",
  "requestTypeId": "35",
  "requestFieldValues": {
    "summary": "This is an incident",
    "customfield_10168": "State 1",
    "customfield_10167": "Incident type 1"
  }
}'
1 Like

Thanks @aagrawal2 for your reply.

Can I use existing custom fields and they are already in the request form.

Seeing your sample

"customfield_10168": "State 1",
"customfield_10167": "Incident type 1"

So if the fieldid ‘customfield_10168’ is the custom field ID you want to map to the attribute given, should it be

"customfield_10168": "incidentState",
"customfield_10167": "incidentType"

By "customfield_10168": "State 1", customfield_10168 is mapped to incidentState's value. It’s not possible to map to the given attribute.

Thanks @aagrawal2

I am still figuring this out, I am sorry if I ask dumb questions.

How do we automate the process, because the third party is a monitoring device that send API to JIRA when alert happens.

Thanks!

Iona