curl json test tool for linux

来源:互联网 发布:思考软件 创新设计 编辑:程序博客网 时间:2024/06/05 05:45

man curl:

-X, --request <command>

              (HTTP) Specifies a custom request method to use when communicat‐
              ing with the HTTP server.  The specified request  will  be  used
              instead  of  the  method otherwise used (which defaults to GET).
              Read the HTTP 1.1 specification for  details  and  explanations.
              Common  additional  HTTP  requests  include  PUT and DELETE, but
              related technologies like WebDAV offers PROPFIND, COPY, MOVE and
              more.

              Normally  you  don't  need  this option. All sorts of GET, HEAD,
              POST and PUT requests are rather invoked by using dedicated com‐
              mand line options.

              This  option  only  changes  the  actual  word  used in the HTTP

              request, it does not alter the way curl behaves. So for  example


 -d, --data <data>
              (HTTP)  Sends  the  specified data in a POST request to the HTTP
              server, in the same way that a browser  does  when  a  user  has
              filled  in an HTML form and presses the submit button. This will
              cause curl to pass the data to the server using the content-type
              application/x-www-form-urlencoded.  Compare to -F, --form.

              -d,  --data  is  the  same  as --data-ascii. To post data purely
              binary, you should instead use the --data-binary option. To URL-
              encode the value of a form field you may use --data-urlencode.

              If  any of these options is used more than once on the same com‐
              mand line, the data pieces specified  will  be  merged  together
              with  a  separating  &-symbol.  Thus,  using  '-d name=daniel -d
              skill=lousy'  would  generate  a  post  chunk  that  looks  like
              'name=daniel&skill=lousy'.

              If  you  start  the data with the letter @, the rest should be a
              file name to read the data from, or - if you want curl  to  read
              the  data  from stdin.  The contents of the file must already be
              URL-encoded. Multiple files can also be specified. Posting  data
              from  a file named 'foobar' would thus be done with --data @foo‐
              bar.

       -H, --header <header>
              (HTTP) Extra header to use when getting  a  web  page.  You  may
              specify any number of extra headers. Note that if you should add
              a custom header that has the same name as one  of  the  internal
              ones  curl  would  use,  your externally set header will be used
              instead of the internal one. This allows you to make even trick‐
              ier  stuff  than  curl would normally do. You should not replace
              internally set  headers  without  knowing  perfectly  well  what
              you're  doing. Remove an internal header by giving a replacement
              without content on the right  side  of  the  colon,  as  in:  -H
              "Host:".  If  you  send the custom header with no-value then its
              header must be terminated with a semicolon, such as  -H  "X-Cus‐
              tom-Header;" to send "X-Custom-Header:".

              curl  will  make  sure  that each header you add/replace is sent
              with the proper end-of-line marker, you should thus not add that
              as a part of the header content: do not add newlines or carriage
              returns, they will only mess things up for you.

              See also the -A, --user-agent and -e, --referer options.
              This option can be used  multiple  times  to  add/replace/remove
              multiple headers.


example:

curl -X POST -H "Content-Type: application/json"  -d '{"ReqName":"edw","ReqType":1,"Action":{"strDeviceID":"111","Value":100}}' http://localhost:8080/


原创粉丝点击