jhthorsen / openapi-client

A client for talking to an Open API powered server
11 stars 17 forks source link

application/json on requests #2

Closed jdalberg closed 6 years ago

jdalberg commented 6 years ago

Hello again :)

I have noticed that when i do a POST towards some function, the Content-Type: application/json header is not set. Shouldn't it always be set?

The missing header results in an error from the remote API I am using.

   'headers' => bless( {
                                                                       'headers' => {
                                                                                      'content-length' => [
                                                                                                            83
                                                                                                          ],
                                                                                      'accept-encoding' => [
                                                                                                             'gzip'
                                                                                                           ],
                                                                                      'user-agent' => [
                                                                                                        'Mojo-OpenAPI (Perl)'
                                                                                                      ],
                                                                                      'host' => [
                                                                                                  '<host>:<port>'
                                                                                                ]
                                                                                    }
                                                                     }, 'Mojo::Headers' ),

If i do a POST on the commandline, i.e.

curl -H "Content-Type: application/json" -X POST -d '{"foo":"bar"}' http://<host>:<port>/api/myfunction

It works.

So at least the service expects the header to be set.

/Jesper

jhthorsen commented 6 years ago

I finally made up my mind, that this is a bug 👍