Giter Site home page Giter Site logo

Comments (11)

njannink avatar njannink commented on June 16, 2024

I'm having the same issues:

error TS2554: Expected 0-1 arguments, but got 2.
error TS2339: Property 'parsedBody' does not exist on type 'HttpOperationResponse'.

any solution yet?

from autorest.typescript.

RikkiGibson avatar RikkiGibson commented on June 16, 2024

bodyAsJson was renamed to parsedBody in ms-rest-js and we recently updated the AutoRest generator to use this new name. The best solution is to use the latest ms-rest-js. Sorry for the inconvenience.

from autorest.typescript.

 avatar commented on June 16, 2024

This has been fixed in the most recent preview versions of ms-rest-js and autorest.typescript.

from autorest.typescript.

clouddra avatar clouddra commented on June 16, 2024

@daschult I am still encountering runtime errors with parsedBody. It always returns undefined even though bodyAsText is has valid json. Can you provide an example of the working cli command to run?

from autorest.typescript.

 avatar commented on June 16, 2024

@clouddra If you use the following line on the command line:
autorest --typescript [email protected]/autorest.typescript@preview <the rest of your command>
then it will use the latest preview version of the AutoRest TypeScript generator. If you're not using the --generate-metadata command line argument, then you'll also need to go into your package.json file and update your ms-rest-js dependency to use the latest preview version as well (0.7.206 as of this comment).

from autorest.typescript.

clouddra avatar clouddra commented on June 16, 2024

yes the property exists for me but it always return undefined. Is it unable to parse the response text?

from autorest.typescript.

RikkiGibson avatar RikkiGibson commented on June 16, 2024

If you look in the generated operation, e.g. getWithHttpOperationResponse(), do you see parsedBody being set in the code?

from autorest.typescript.

clouddra avatar clouddra commented on June 16, 2024

parsedBody is not set. bodyAsText is set though.

from autorest.typescript.

RikkiGibson avatar RikkiGibson commented on June 16, 2024

I would try forcing using the latest generator and runtime with [email protected]/autorest.typescript@preview in autorest and npm i ms-rest-js@preview in your package.

from autorest.typescript.

tomlm avatar tomlm commented on June 16, 2024

I see this if the REST API doesn't set the content-type to "application/json". In my case it was “application/octet-stream”, which causes the AutoRest generated code to not parse the content as json into the parsedBody property.

from autorest.typescript.

RikkiGibson avatar RikkiGibson commented on June 16, 2024

We might be able to do something like prefer the Content-Type given in "produces" in Swagger to the Content-Type we see at runtime. Do you mind opening an issue for this?

from autorest.typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.