What is the value for request.header.Content-Type to upload CWL file to hosted workflow using SwaggerUI?


I got the hosted workflow to register with Python using “requests” module and now trying to upload the “Dockstore.cwl” file of the following content to the workflow:

cwlVersion: v1.0\nclass: Workflow

If I don’t specify ‘Content-Type’ or specify anything other than ‘application/json’ for the request header, I get "HTTP 415 Unsupported Media Type” exception from the PATCH request.
If I specify ‘Content-Type’: ‘application/json’ for the request, I am getting a response of the following content (as I would expect):
{'code': 400, 'details': "Unrecognized token 'cwlVersion': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')", 'message': 'Unable to process JSON'}

I tried to add the file manually using the Dockstore UI and examined the request with developer tools. The confusing part is that request header shows exact same content in YAML format as I am trying to add but using ‘application/json’ as Content-Type and the content is added to the file:

Content-Type: application/json
content: "cwlVersion: v1.0\nclass: Workflow"

The content is definitely not of a JSON format, but somehow works when the request is handled by Dockstore UI request. Does Dockstore UI converts CWL to YAML format internally?

Does anybody know what the value do I need to specify to upload CWL in YAML format using SwaggerUI? SwaggerUI docs show application/json as the only format for the request body.

Any clarification is greatly appreciated, thanks!

Hi Masha,

The request body needs to be JSON, not plain text. In developer tools, if you right-click on a request, you can “copy as curl”, and you can see the full request being made as a curl command. Essentially, you need to pass a SourceFile in JSON form. See here.


Thank you so much for clearing up my confusion, Charles! This is very helpful :slight_smile: