Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default request Content-Type header and parameter in body as object #1010

Closed
srihakum opened this issue Apr 10, 2017 · 3 comments
Closed

Default request Content-Type header and parameter in body as object #1010

srihakum opened this issue Apr 10, 2017 · 3 comments
Assignees

Comments

@srihakum
Copy link

This issue is in further reference to #991

With version 3.0.5 a swagger client instance tries to make an API request the following issues are observed

  1. Content-Type header is not added in the request.
  2. If a parameter used in HTTP body is added to the request the client expects it to be in the string format.

However while using 2.0.32 there is no need to set these explicitly. So is there a way we can get back the old behaviour with latest version, like adding "application/json" as default content type and the adding body parameter as JSON object rather than string.

Code example:

var Swagger = require('swagger-client');
new Swagger({
    "url":"https://staging.cloud-elements.com/elements/api-v2/elements/44/docs"
})
    .then(function (client) {
        client.apis.zohocrm.createAccount({"Authorization":"...","body":{"Account Name":"XYZ1"}})
            .then(function(response){
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            });
    }).catch(function (error) {
    console.log(error);
});
@dwilson6
Copy link

The content-type issue is documented in #995
The object serialization issue is captured by #1006

@camsjams
Copy link

Is 3.x stable? These issues create unexpected behavior and reduce the usefulness of this wrapper.

@webron
Copy link
Contributor

webron commented Apr 19, 2017

Thanks @dwilson6. Closing this in favor of the other two tickets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants