Reputation: 1
Using Cloudify latest REST plugin I'm trying to send request with octet-stream content type.
Tried several ways to send the data but with no success
My REST template looks like this:
rest_calls:
- path: /v2/projects/{{ PROJECT_ID }}/import?name={{ PROJECT_NAME }}
method: POST
headers:
Content-type: application/octet-stream
Content-Length: 28022
payload:
{{ PROJECT_BINARY }}
response_format: json
recoverable_codes: [400]
response_translation: [project_info]
response_expectation:
- [ 'name', '{{ PROJECT_NAME }}' ]
And this is how the parameters were set: execute
params {u'PROJECT_ID': u'8c76f840-fb1f-401f-b348-22b432caeef2', u'PROJECT_NAME': u'isis', u'PROJECT_BINARY': u'504b03041400080000003757814e'}
template
templates/create_and_import.yaml
I initialize the PROJECT_BINARY parameter (and the other variables) using get_input function. I can see in Cloudify log that the variables are set to the correct value.
However, I get the following error when running install workflow:
'install' workflow execution failed: RuntimeError: Workflow failed: Task failed 'cloudify_rest.tasks.execute' -> while constructing a mapping
in "<string>", line 8, column 9:
{{ PROJECT_BINARY }}
^
found unacceptable key (unhashable type: 'dict')
in "<string>", line 8, column 10:
{{ PROJECT_BINARY }}
^
Upvotes: 0
Views: 168
Reputation: 259
One of possible solutions can be used "prerender==true". See here. n such case we render {{PLACEHOLDERS}} and then parse YAML. It could be good solution for some cases. It will work for any content except broken JSON (unclosed quotes and dicts) and content with new lines.
If you can use pre-created files - you can try to use raw_payload. See here.
Or as solution that can be tested:
====
rest_calls:
- path: /v2/projects/{{ PROJECT_ID }}/import?name={{ PROJECT_NAME }}
method: POST
headers:
Content-type: application/octet-stream
Content-Length: 28022
payload: "{{ PROJECT_BINARY }}"
response_format: json
recoverable_codes: [400]
response_translation: [project_info]
response_expectation:
- [ 'name', '{{ PROJECT_NAME }}' ]
====
Upvotes: 0