Code Monkey home page Code Monkey logo

Comments (9)

jkbrzt avatar jkbrzt commented on April 28, 2024

@avisser It would be nice not having to escape it but the JSON simply needs to be valid after the arguments have been processed by the shell, so it's unfortunately necessary. Otherwise it would require an error-correcting JSON parser to allow unquoted strings.

You can also wrap the whole argument with single quotes ('purchased_licenses:=["android.test.purchased"]'), or It might be easier to pass the JSON in via stdin, such as:

echo '{"purchased_licenses": ["android.test.purchased"]}' | http localhost:8888/api/learn/license_check

# or from a file

http localhost:8888/api/learn/license_check @payload.json

(Tip: POST is default here because you are sending data with your request so you can omit it.)

from httpie.

avisser avatar avisser commented on April 28, 2024

I was worried that might be the case. Thanks for the alternatives.

Might I suggest using one of your examples in the readme.rst?

The fact that

blah:=[1,2,3]

and

blah:=["1","2","3"]  #the quotes get stripped, but bare numerals are fine

both work drove me crazy for a few minutes.

Great utility. Keep up the good work.

from httpie.

jkbrzt avatar jkbrzt commented on April 28, 2024

Good idead, I'll update the README. Cheers

from httpie.

asemx avatar asemx commented on April 28, 2024

Still getting below error when i pass with quotes from cmd line 'meals:=["ham", "spam"]' (i notice in the documentation you use = and not := though I tried both)

http-script.py: error: argument REQUEST ITEM: "spam]'" is not a valid value

from httpie.

asemx avatar asemx commented on April 28, 2024

to pass string arrays in json from cmd line, i found the below option working:

meals:=["ham","spam"]

thanks btw for this great project.

from httpie.

jkbrzt avatar jkbrzt commented on April 28, 2024

It looks like your shell is eating the quotes for some reason. The first form works fine in bash:

Screen Shot 2013-03-16 at 16 48 04

from httpie.

asemx avatar asemx commented on April 28, 2024

meals:='["ham","spam"]' with (or without) quotes doesn't work on windows cmd. I have to use '' escapes.

from httpie.

jkbrzt avatar jkbrzt commented on April 28, 2024

I misread you comments, but have corrected my answer in the meantime. Sorry for the confusion.

Okay, I understand, there is this nested quoting incompatibility between bash and cmd.exe. I will update the docs accordingly. Thanks.

from httpie.

afolaran avatar afolaran commented on April 28, 2024

Hello.

I have just installed httpie and I am trying to perform some aggregate queries on a data base on my local machine. I got the error message;

http-script.py: error: argument REQUEST_ITEM: "[" is not a valid value

What can I do to resolve this? I have tried several options but no success. Below I attach a screenshot of my console

error page

from httpie.

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.