I'm running a tomcat server with a REST service on localhost.
This url typed in the browser gives me a json response: http://localhost:8080/a/rest/dataset/list
But when I use curl: curl http://localhost:8080/a/rest/dataset/list the response is HTML code with a 404 error from the server.
What am I missing in the curl command?
Tomcat may be waiting for a specially formatted HTTP request from the user. As you are expecting a response in json, you should probably forward the following argument to curl :
-H 'Content-Type: application/json'
Also, you may always specify to whatever HTTP server the response you are expecting him to return. A lot of back-end application based on HTTP are issuing a response given the HTTP request.
Related
I am doing automation to get opening tickets details so i am executing web service call in FreshService ticketing tool.
Below is my web service call using CURL and GET
curl -X GET -H 'Content-Type: application/json' -v -i 'https://support.XXXXXXX.com/helpdesk/tickets/9725.json?-u=ASDDDECDFF%3AX%20'
When i am executing only getting below response in body.
{
"require_login":True
}
But my output joson file visible after opening that url in browse i can see json file, so i execute below vbsctipt to send HTTP request for read the JSON file but same ""Require_login":True" coming.
Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "https://support.XXXXXXX.com/helpdesk/tickets/9723.json", False
o.send
msgbox o.responseText
So my expectation to get JSON file in body part of web service response or through vbscript get JSON file store locally.
Appreciate any other light wight tool or easy approach. More about Fresh service API details https://api.freshservice.com/#introduction
After i encoded my authentication key with base64 and addd Authorization as header and its working now.
Update Web service URL,
curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic XXXXXYYYYYZZZ' -v -i 'https://support.XXXXX.com/helpdesk/tickets.json'
I'm trying to connect to ActiveCollab API trial account with Postman.
I'm stuck at the beginning, because I can't get the required token.
I tried unsuccessfully (got an error) to run the below command in CMD and Powershell:
curl -XPOST -d 'email=mymail#gmail.com&password=myPassword' https://activecollab.com/api/v1/external/login
Error:
curl: no URL specified!
curl: try 'curl --help' for more information
'password' is not recognized as an internal or external command,
operable program or batch file.
then I tried to make the call with postman GET and POST method
url: https://activecollab.com/api/v1/external/login?email=mymail#gmail.com&password=myPassword
with and without parameters, with basic authentication, no authentication and APIkey authentication.....
Also tryed with https://app.activecollab.com/205491/issue-token
with body type json:
{
"username": "mymail#gmail.com",
"password": "maypassword",
}
and with username and password in headers, with no success
Can anybody make or describe how to make a postman call to get the token and an simple example how to get/add project.
Does anybody know if this documentation is up to date?
It's described at this page:
https://developers.activecollab.com/api-documentation/v1/authentication.html
Your correct endpoint would be: https://app.activecollab.com/205491/api/v1/issue-token
I have a Zabbix web monitoring task where I need to pass in JSON data to the URL via a http post. For example, the curl command to run this request is:
curl -H "Content-Type: application/json" --data #myData.json https://example.net
When I am configuring the Zabbix web monitoring task, where do I put this JSON data?
I see under the "Step of the web scenario" there are fields for 'Post', 'Variable', and 'Headers'. Does the JSON data go directly in one of those fields?
curl --data => it's POST request => paste your JSON data into Zabbix Post field + you need to set JSON header in the Zabbix Headers field: Content-Type: application/json.
I am having trouble requesting the current status of a resumable upload. Based on the Google Documentation, the following request should return a Range header with the current range google has of my upload, but I keep getting the following response:
Failed to parse Content-Range header
Here is my curl request:
curl -H "Content-Range: bytes */1443452365" -H "Content-Length: 0" locationUrl -X PUT
I have also tried "bytes */*" and "*/*" for the Content-Range header, but no luck.
Any ideas?
First, you need to check the correct request format like the sample given below:
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"id":100}' http://localhost/api/postJsonReader.do
And, discussed in other command-line tools, when sending raw HTTP data, be aware that the POST and PUT operations will require computing the value for a Content-Length header. You can use the UNIX tool wc to compute this value. Place all the content of the HTTP body into a text file such as template_entry.xml (example used above) and run wc -c template_entry.xml. It is often difficult to debug if you accidentally use an incorrect value for the Content-Length header.
Lastly, you can request the status between chunks, not just if the upload is interrupted. If the upload request is interrupted, follow the procedure outlined in resume an interrupted upload.
I have a simply Json file stored on a ftp and when I call the url http://myurl/example.json, I receive a plain/txt type file.
How can I solve the problem ?
Thanks for any help :)
Whether file is stored on server via FTP or any other method is irrelevant. What matters is that you are requesting the file over HTTP. So you need to work on your HTTP request and response headers.
One thing you may try first, is setting the headers of your request. Here's a curl example I randomly found, that shows that (application/json is the interesting part).
curl -i -u application_name:application_password --data '{"value": "my_password"}' http://localhost:8095/crowd/rest/usermanagement/1/authentication?username=my_username --header 'Content-Type: application/json' --header 'Accept: application/json'
What also matters is the response headers that the server assigns. If you have access and rights, ensure those are set, too. A good starting point: review current response headers.