External ID Mismatch on Jira Asset Imports API

Alex Barker November 21, 2023

I am trying to create an external app to automatically import data into assets from an external source. We have an existing object type that we want the external app to import data into but attempting to call the PUT Mapping endpoint on the existing schema gives "EXTERNAL_ID_MISMATCH" errors

... 
"dataValidationErrors": [

        {

            "code": "EXTERNAL_ID_MISMATCH",

            "location": "object-type/users"

        },
...

Trying to get the existing external IDs through GET schema-and-mapping does not return any external IDs currently set, so I am not sure what it is mismatching with.

The schema & mapping upload works for a schema that does not already exist.

Am I missing something here? It would be nice if the documentation for the imports API could be improved.

Edit:
I have found [JSDCLOUD-13760] Missing external IDs from schema and mapping. which vaguely describes what I am experiencing

3 answers

1 vote
Pedro Arroyo May 24, 2024

Hi,

Trying to get the existing external IDs through GET schema-and-mapping does not return any external IDs currently set, so I am not sure what it is mismatching with.

`GET /schema-and-mapping` does return externalIds. I've been working on an Assets project where the schema was configured through the GUI and I get externalIds just fine. Maybe it has been enhanced since you originally faced this issue (I'm new to Assets). What I have found, though, is that it won't return the attributes of child object types when the schema is configured to Inherit all attributes.

Alex Barker June 5, 2024

Hey,

Looks like newly created fields get an externalId created but not old ones. Makes sense based on when the new JSON schema is dated (2023_10_19)

Partial response from GET mapping on old vs new field:

{
    "name": "Job Title",
    "description": "",
    "type": "text",
    "label": false,
    "minimumCardinality": 0,
    "maximumCardinality": 1,
    "unique": false
},
{
    "externalId": "cmdb::externalId/xxxxxxxxxxxxxx",
    "name": "Test F",
    "description": "",
    "type": "text",
    "label": false,
    "minimumCardinality": 0,
    "maximumCardinality": 1,
    "unique": false
},

Now to figure out if its possible to either set the externalIds or get one generated that I can use...

Like Steffen Opel _Utoolity_ likes this
Pedro Arroyo June 5, 2024

I'm not entirely sure what is this that you're seeing. GET /schema-and-mapping will always return all object types and it's attributes including their externalId regardless if it's newly created or not.

When you use the Imports API you can PUT the mapping without externalIds (the rule is either you send them all, or you don't send any at all). In my experience, the path of least frustration is to let Assets assign the externalIds. The best way to do this is to configure the schema using the GUI, and then GET /schema-and-mapping to retrieve the assigned externalIds and use them in the object mapping for the import.

Alex Barker June 6, 2024

GET /schema-and-mapping is returning all the object types and attributes just fine, but is definitely not returning externalIds for any object type or attribute made before ~Oct 2023.

Because of this, I cannot send the mapping without getting an EXTERNAL_ID_MISMATCH on an external Id that is not shown to me.

Do you have any schema's that you defined before Oct 2023? Would love to see if this is an issue on multiple instances or if I am just doing something wrong, somewhere.

Thanks :)

Pedro Arroyo June 7, 2024

Ah! There's an inconsistency then. I've just started working with Assets, so I don't have something older to compare to. But what you're saying seems like a bug to me.

While I have not tried it yet, I've read there's a REST API separate from the Imports API. Probably you could work around the issue with it.

Sorry I could not be of more help. I think you should report this inconsistency to Atlassian.

:)

Like # people like this
1 vote
thomas
Contributor
January 18, 2024

I believe it is impossible. I am in the same boat.

The schema you've created via the GUI cannot be used for your external import because the external import requires a "schema:" defined in the JSON, aka its own schema.

You get an EXTERNAL_ID_MISMATCH error because you've probably defined one or many objects in your JSON schema with the SAME name than what's in your current GUI schema/workspace.

e.g:

{"jsonValidationErrors":[],"dataValidationErrors":[{"code":"EXTERNAL_ID_MISMATCH","location":"object-type/foobar"}

In your JSON, look under the object-type/foobar and change the associated name to something else and you will see it will import your object fine but it will create a new one!

I am unsure if what you/we are trying to do is possible. The import rest API feels more like 'infrastructure-as-code' and must drive the WHOLE schema but is seriously limited in its abilities to do so. So frustrating.

Ref:

Pedro Arroyo June 5, 2024

I beg to differ.

The schema used for the Imports API is (almost) the same as the one created through the GUI.

I have targeted blank schemas and created them fully, as well as patching the schema and the object mapping.

When there's an EXTERNAL_ID_MISMATCH message it usually means that in your object mapping the externalId is not the correct one. It's very easy to make mistakes when editing the JSON manually, specially if it's a big schema.

Can you provide a sample output of a GET /schema-and-mapping call?

0 votes
Alex Barker June 25, 2024

Wasn't able to find a solution to use the 2023 JSON schema, however I did manage to get the old JSON schema working that didn't use external_ids.  

Here is the old documentation from wayback machine for the 2021 schema:
https://web.archive.org/web/20230925163409/https://developer.atlassian.com/cloud/assets/imports-rest-api-guide/schema-and-mapping/

Would much rather have this fixed instead of using an old API that will probably get deprecated and/or break at some point, but this is a working solution.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events