curl on Windows, error passing -d option

Posted on 2014-07-10
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


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?
Question by:Anthony Lucia
    1 Comment
    LVL 32

    Accepted Solution

    Common problem in windows.
    Place the JSON in a file and do
    curl -d @filename -H "Content-Type: application/json" -i  http://localhost:8081

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    The task of choosing a web design company to build a website for your business should never be taken in a light manner. Provided the fact that your website will act as a representative to your business and will be responsible for imposing an online …
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now