I have trouble creating object with a Project attribute using "Create object": https://developer.atlassian.com/server/jira-servicedesk/rest/v1103/api-group-assets---object/#api-assets-1-0-object-create-post
It's working fine for the Text attributes,
I have tried:
"objectAttributeValues": [ { "value": "project key" } ]
"objectAttributeValues": [ { "value": "project name" } ]
"objectAttributeValues": [ { "key": "project key" } ]
"objectAttributeValues": [ { "value = { "key": "project key" } } ]
How to Send a Project-Type Attribute in the Create Request
The POST structure to create the object is as follows (simplified):
json
POST /rest/assets/1.0/object/create
{
"objectTypeId": 2154,
"attributes": [
{
"objectTypeAttributeId": 1234, // ID of the "Project" attribute in the Assets schema
"objectAttributeValues": [
{
"project": {
"key": "PROJKEY" // or "id": 10000
}
}
]
}
]
}
Key Points:
Use project, not value
For a Project-type attribute, the value should be placed in the project field, for example:
json
"objectAttributeValues": [
{
"project": {
"key": "MYPROJ" // project key
}
}
]
You need the correct objectTypeAttributeId
This is the ID of the attribute within the Assets object type (not the project ID).
You can find this ID via:
REST: GET /rest/assets/1.0/objectType/{objectTypeId}/attributes
Or by inspecting the UI (it may appear in the URL or network calls).
More "Realistic" Complete Example
Assume:
objectTypeId = 2001 (object type “Server”)
Attribute “JSM Project” (type Project) has objectTypeAttributeId = 3005
You want to link to the project with key SUPPORT
Request:
bash
curl --request POST \
--url 'https://your-jira/rest/assets/1.0/object/create' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"objectTypeId": 2001,
"attributes": [
{
"objectTypeAttributeId": 3005,
"objectAttributeValues": [
{
"project": {
"key": "SUPPORT"
}
}
]
}
]
}'
If preferred, you can use the project ID:
json
"project": { "id": 10001 }
This should help if any problems arise; please post them here so the community can assist you.
I have the objectTypeAttributeId. Tried this, where "IK" is the key of the jira project:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's working, thank you!
objectAttributeValues needs to be an array, like so:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.