REST multipart/form-data


(Matthew Harding) #1

Matrix Version: 5.3.2.1

Hello

We have been using a Call REST Resource trigger action make a call to a CKAN docs instance to update a resource with a new URL using the resource_update function.

We would like to change to uploading the file into CKAN however it states that it requires a multipart/form-data request.

Is the Call REST Resource trigger action capable of handling a multipart/form-data request and if so how would i go about writing it?

Our current request body is:

{“id”: “%asset_metadata_func.resource_id%”,
“url”: “%asset_url%?timestamp=%asset_updated^date_format:Y-m-dTH-i-s%”,
“description”: “%asset_metadata_description%”,
“size”: “%asset_metadata_func.resource.size%”,
“expiration-date”: “%asset_updated_d%/%asset_updated_m%/%asset_updated_Y^add:1%”,
“last_modified”:"%asset_updated^date_format:Y-m-dTH-i-s%",
“webstore_last_updated”:"%asset_updated^date_format:Y-m-dTH-i-s%"}

Thanks


(Bart Banda) #2

Yep, you just need to mimick what your browser is doing when you are using a form that is submitting files.

For example, something like this:

You can also try it out in Postman to see how it’s done there and look at the raw data being sent and copy that format over to the REST asset.


(Matthew Harding) #3

Thanks Bart. I’ll have a go and let you know.