Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

curl on Windows, error passing -d option

Posted on 2014-07-10
1
Medium Priority
?
1,803 Views
Last Modified: 2014-07-11
I am running curl on Windows,

and can not quite pass a JSON string to the web service successfully

FIrst a successful attempt, notice I do not have any spaces between the bracket and the first string within JSON,
in other words:  -d '{"creditcardnumber"

C:\curl>curl -H "Content-Type: application/json" -i -d '{"creditcardnumber":"555
5222233334444"}' http://localhost:8081
HTTP/1.1 200 OK
Date: Thu, 10 Jul 2014 10:54:40 -0700
Content-Type: application/json
Content-Length: 37

'{creditcardnumber:5555222233334444}'

Open in new window


Right now I am not worried about the response from the web service, but in the above example, the passing of the JSON worked well.

Now for an unsuccessful example, where I pass spaces just after the bracket on the "-d" option:

C:\curl>curl -H "Content-Type: application/json" -i -d '{ "creditcardnumber":"55
55222233334444" }' http://localhost:8081
curl: (3) Port number out of range
curl: (3) [globbing] unmatched close brace/bracket in column 1
HTTP/1.1 200 OK
Date: Thu, 10 Jul 2014 12:51:51 -0700
Content-Type: application/json
Content-Length: 2

'{

Open in new window


Let me repeat the curl error in the above statement

curl: (3) [globbing] unmatched close brace/bracket in column 1

Open in new window


So how can I handle sending the -d JSON test without getting this issue?
0
Comment
Question by:Anthony Lucia
1 Comment
 
LVL 33

Accepted Solution

by:
shalomc earned 2000 total points
ID: 40190768
Common problem in windows.
Place the JSON in a file and do
curl -d @filename -H "Content-Type: application/json" -i  http://localhost:8081
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question