Hi there,
If I manually create a record in Assets I can use a space when entering a name.
Using the API I am getting an error due to the space.
Is there some sort of encoding that needs to happen for the 'Name' attribute which is the main Label attribute when creating a record via the API.
"Invoke-RestMethod : {"errorMessages":["AQL \"Name = Bowen Hills\" has invalid syntax at position 13 with error message \"mismatched input 'H' expecting {, ' '}\""],"errors":{}}"
Is the error, if I remove the space then there is no issue.
Here is an example of the body
"objectTypeId": 13,
"attributes": [
{
"objectTypeAttributeId": 120,
"objectAttributeValues": [
{
"value": "Barrow Island"
}
]
},
{
"objectTypeAttributeId": 146,
"objectAttributeValues": [
{
"value": "Gorgon Project - LNG Construction Site"
}
]
Attribute 120 is the label... fails. 146 is just a normal text field, imports fine full of spaces. it is specific to the attribute set as the label?!
Hi Steven,
This is interesting. I have hundreds of assets with spaces in the Label Attribute and never seen an error like that.
In the attributes of your object schema, what is the Type and Type Value set to?
Suzi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just the normal Default Text.
I can import manually from a CSV, manually create in Assets all with spaces..
just the API fails to create when there is a space.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Only other thing I can think of is have you put a regular expression in validation for the attribute?
Otherwise, I'd probably recommend logged a ticket with Jira Support.
Suzi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you have a suggestion for the validation. I can encode the text but it comes over with a " " around it.
I was trying to also see if I could parse it away after the data appears? do you know if that is possible?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm that's a bother. I think I might be out of the depth on this one. Not sure what's causing the issue. I can't see anywhere in the Jira documentation that says you can't use spaces in labels either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yeh you can use spaces in labels normally (manual csv import or manually creating an object).
It just seems that when it is coming over via the API the AQL is missing the fact it's a string.
I can import them if they have " " around them but then I need to get rid of that AFTER it is in Assets.
I have flung this over to Atlassian.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ah such a dope... I was mucking up my iql call.
I have a function which builds up a key to go look into Assets to find a match or not to either create or update and Object.
I had this;
$iql = $key.name + ' = ' + $key.value
Which for names with spaces was building this Name = First Last
Obviously with that being added to the iql, it was failing.
I changed it to this
$iql = $key.name + ' = ' + '"' + $key.value + '"'
$url = "https://api.atlassian.com/jsm/insight/workspace/$workspaceId/v1/object/navlist/iql"
Now it comes out as Name = "First Last" and what do you know, no error!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's great news Steven!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
On a related question: what field is used for JSM to figure out an asset is duplicate while importing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I set a variable in Powershell as part of a mapping function that builds a PSCustomObject;
$mappings = [PSCustomObject]@{
Imp_Name = [PSCustomObject]@{name="Name"; id=164; value=$user.Name}
in another function I set that as the Key
$key = $data.Imp_Name
$found = Insight-FindObject $key
Then in the FindObject function I build up an IQL statement using the key and pass $found back as yes or no basically.
function Insight-FindObject ($key) {
$iql = $key.name + ' = ' + '"' + $key.value + '"'
$url = "https://api.atlassian.com/jsm/insight/workspace/$workspaceId/v1/object/navlist/iql"
$headers = @{
If it finds it, then it will update, if it doesn't find it then a new Object will be created.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.