How to reuse captured bytes of previous response as `multipart/form-data` field in next request
Context
I am currently working on FlowG's backup feature (sorry for self-promotion). The End-To-End test suite of the API is written with Hurl (loves it by the way, thanks for the great work).
I'm trying to implement the backup&restore test. The idea is to send the API request for backup-ing, capturing the response body (which is the actual backup bundled in a binary file) as bytes, and then reuse the captured bytes as part of the "restore" API request.
I'm unsure if I'm misreading the docs, or if they are lacking, or if the feature simply does not exist.
Test case
I tried the following:
GET http://localhost:5080/api/v1/backup/logs
Authorization: Bearer pat:{{admin_token}}
HTTP 200
[Captures]
logs_backup: bytes
POST http://localhost:5080/api/v1/restore/logs
Authorization: Bearer pat:{{admin_token}}
[Multipart]
backup: {{logs_backup}}
HTTP 200
And:
GET http://localhost:5080/api/v1/backup/logs
Authorization: Bearer pat:{{admin_token}}
HTTP 200
[Captures]
logs_backup: bytes
POST http://localhost:5080/api/v1/restore/logs
Authorization: Bearer pat:{{admin_token}}
Content-Type: multipart/form-data; boundary=----test
```
----test
Content-Disposition: form-data; name="backup"; filename="logs.db"
Content-Type: application/octet-stream
{{logs_backup}}
----test
```
HTTP 200
But in both cases, I get the following error:
error: Unrenderable expression
--> spec/backup.hurl:22:11
|
| POST http://localhost:5080/api/v1/restore/logs
| ...
22 | backup: {{logs_backup}}
| ^^^^^^^^^^^ expression with value hex, <big hex value omitted>; can not be rendered
Execution context
- Hurl Version (
hurl --version):
hurl 6.0.0 (unknown) libcurl/8.12.1-DEV OpenSSL/3.0.13 zlib/1.3
Features (libcurl): alt-svc AsynchDNS HSTS IPv6 libz SSL UnixSockets
Features (built-in): brotli
I managed to get it working using:
GET http://localhost:5080/api/v1/backup/logs
Authorization: Bearer pat:{{admin_token}}
[Options]
output: backup/logs.db
HTTP 200
POST http://localhost:5080/api/v1/restore/logs
Authorization: Bearer pat:{{admin_token}}
[Multipart]
backup: file,backup/logs.db;
HTTP 200
Though, it would be nice if I could avoid using a file.
Hi @linkdd that's exactly what I was going to suggest to you 🤣.
We keep this issue open and we're trying to improve this use-case without creating a temp file.