1

I'm using the following jsonapi GET request to retrieve product variations for a product:

/jsonapi/commerce_product/default/0ea927c7-b62d-45c9-8bec-dc3d16215276/variations?include=field_images

However, the response does not include the file url for the media:

{
"type": "media--image",
"id": "6af50149-ae35-4a3b-802d-b21c5d863235",
"links": {
"self": {
"href": "http://myurl/en/jsonapi/media/image/6af50149-ae35-4a3b-802d-b21c5d863235?resourceVersion=id%3A4"
}
},
"attributes": {
"drupal_internal__mid": 4,
"drupal_internal__vid": 4,
"langcode": "en",
"revision_created": "2021-09-03T08:03:04+00:00",
"revision_log_message": null,
"status": true,
"name": "image-940375_1920.jpg",
"created": "2021-09-03T08:02:55+00:00",
"changed": "2021-09-03T08:02:55+00:00",
"default_langcode": true,
"revision_translation_affected": true,
"metatag": null
},
"relationships": {}
},

How do I add the media file url to the request?

1 Answer 1

1

I figured it out:

/variations?include=field_images.field_media_image&fields[file--file]=uri,url
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.