Static Headers


#1

Hi,

I’m hitting a problem because of whitespace within one of my headers. My API requires this :

Authorization: AUTH f7e097f3-f3a5-e977-2736-7b123cdee500

Which translates to the following RAML:

headers:
        Authorization:
                    description: |
                       Used to pass the Aperture authentication token to Aperture.
                    type: string
                    required: true
                    example: VENAFI 650cc3ff-f0e1-3c60-d8f6-c9d058b2a3ae

I tested this in curl e.g.

curl -H Authorization: AUTH f7e097f3-f3a5-e977-2736-7b123cdee500 .....

and it works as expected, however when I try using the RAML API designer my API throws an error. I’ve also tested the API using the Python requests library and that also works as expected. Am I missing something here?


#2

OK - So I think I worked out my issue. It wasn’t the whitespace that was causing the issue. The header was not being added to the request. How can add static headers to my RAML definition so that will work with “Try-it”. e.g.

Authorization: AUTH f7e097f3-f3a5-e977-2736-7b123cdee500  

I tried using the default parameter in the definition but that does not seem to work.


#3

Hi Carl,

the default parameter is part of your specification. That means your server code is responsible to check if the header exists and if not to add the defined default value. Are you using a real implementation when trying your API in the API console (via “Try-It”) or did you enable the mocking service?

Cheers,
Christian


#4

Hi Carl,

I just realised that you say required: true for the Authorization header. That is why the Try-It gives you that error. So you always have to provide the information even for the Try-It feature. In a next release of the console we will provide a feature which automatically add your example/default when using Try-It without you having to type it in everytime.

Does that answer your question?

Cheers,
Christian


#5

Thanks Christian,

Yes that answers my question. Any ideas as to when the next version of the console will be available?

Carl