Hi I am trying to create defect from Rest API into HPALM.
I am using following command. I am getting an error:
HTTP/1.1 400 Unknown Version
C:\Adwait>curl -D- -X POST --data-binary #C:\Adwait\HPCreateDefect.json -H "Authorization: Basic RGVtb" -H "Content-Type:application/json" "http://ServerURL:8080/qcbin/rest/domains/DEMO_PURPOSE\/projects/DEMO_01/defects HTTP/1.1" -k
HTTP/1.1 400 Unknown Version
Content-Length: 0
Connection: close
Server: Jetty(9.1.4.v20140401)
#Adwait please check how you write the link above.
Even if suggested in some libraries from HP, you do not have to add the HTTP/1.1 at the end of the link used.
Please check and close the query itself. I had in the beginning same problem creating a python interface for the QC REST API.
Have a nice day!
Related
When I do:
curl https://example.com/my/ressource \
-H "Content-Type: application/json" \
--data '{"itemid":["123","456"]}' \
-u myuser
I get HTTP 403 Forbidden error code. If I use a get request it works, e.g.
curl https://example.com/my/ressource
Works fine. Also if I disable basic authentication at the server side the above post request works fine.
The server is an Apache 2.4 and it is acting as a reverse proxy.
What is wrong with the post request?
It turned out, that in the above case Apache is used as a reverse proxy and the server behind Apache could not handle Authorization, so the solution was to remove this header with:
RequestHeader unset Authorization
After posting json format data to server using curl in windows command prompt(cmd), I'm testing the response data now, got a 'Bad request' message.
I've checked the request format, too.
cmd:
curl -i -X POST -H "Content-Type: application/json" -d '{ "isbn":"123442123, 97885654453443","title":"Learn how to build modern web application with MEAN stack","author": "Didin J.","description":"The comprehensive step by step tutorial on how to build MEAN (MongoDB, Express.js, Angular 5 and Node.js) stack web application from scratch","published_year":"2017","publisher":"Djamware.com" }' localhost:3000/api
And then,
HTTP/1.1 400 Bad Request
X-Powered-By: Express
Content-Type: text/plain; charset=utf-8
Content-Length: 11
ETag: W/"b-EFiDB1U+dmqzx9Mo2UjcZ1SJPO8"
Date: Wed, 05 Sep 2018 01:41:55 GMT
Connection: keep-alive
Bad Request
What's wrong? please help me.
You wrote the title as 'curl issue...', but i think curl has never any issue, because it is very widely used.
And your request data have no fault.
As my experience, problem would be exist in DB connection.
please check and check the accuracy of MongoDB connection.
I'm using cURL to connect to a remote host. Some of my commands execute just fine (like authentication via POST and pulling information via GET). I'm getting a weird error when trying to use a POST to add information with regards to content length. This is my syntax;
curl -k -i -b sessionid -X POST https://hostname/BeyondTrust/api/public/v3/Workgroups/apiTest/Assets?AssetName=string&DnsName=string&DomainName=string -H "Content-Type: application/json" -H "Authorization: PS-Auth key=b8e1...2c27; runas=userName; pwd=[password]" -d ""
This is my output;
[1] 58164
[2] 58165
-bash: -H: command not found
[2]+ Done DnsName=string
HTTP/1.1 411 Length Required
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Oct 2017 14:29:12 GMT
Connection: close
Content-Length: 344
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
I've researched it, and this is a common problem, apparently. -d "" does not fix and have tried --ignore-content-length and Content-Length: 0 in the headers, but I still have the same issue. Can someone point me in the right direction?
You need to quote the URL because it contains some special shell characters.
This output tells you something went wrong:
[1] 58164
[2] 58165
-bash: -H: command not found
[2]+ Done DnsName=string
Your command got split into multiple jobs and resulted in some errors because of the & in the URL's query string.
Putting the URL in double-quotes " will fix the issue.
curl -k -i -b sessionid \
-X POST \
"https://hostname/BeyondTrust/api/public/v3/Workgroups/apiTest/Assets?AssetName=string&DnsName=string&DomainName=string"
This way your URL will be interpreted properly and the shell won't try to start it in the background.
I'm trying to use the replication in CouchDB.
When I enter the following code :
curl -X POST http://127.0.0.1:5984/_replicate \
-d ’{"source":"musica","target":"musica-replica"}’
I receive the following error:
{"error":"bad_content_type","reason":"Content-Type must be application/json"}
Can you help me?
As the reason said, you need to add a header that looks like: Content-Type: application/json
You can add this to curl via the -H "Content-Type: application/json" flag.
I'm trying to use wget 1.11.4 running on Windows Server 2003 to do some JSON with a web site. I can retrieve info OK but I can't send any. I'm not positive that my JSON is formatted correctly but there seems to be a more fundamental problem.
If I do:
wget --header="Authorization: Bearer <redacted>" --no-check-certificate --post-data="{'workspaces':{'title':'CMC Regulatory Support','creator_role':'maven'}}" https://api.mavenlink.com/api/v1/workspaces.json
I get a JSON error back from the site "ERROR 422: Unprocessable Entity." But if I add another --header:
wget -S --header="Authorization: Bearer <redacted>" -–header="Content-Type: application/json" --no-check-certificate --post-data="{'workspaces':{'title':'CMC Regulatory Support','creator_role':'maven'}}" https://api.mavenlink.com/api/v1/workspaces.json
I get:
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
wget: invalid option -- û
Usage: wget [OPTION]... [URL]...
Try `wget --help' for more options.
but the manual clearly states that multiple --header switches are allowed, and I see that swithc used in examples on the web?. WTF?
Your second --header parameter before the Content-Type contains different dashes.
-–header="Content-Type
If you fix it wget will send the request.