How to call some api url with some header in it using the bat file? - api

Following is the bat file code for executing the URL from a bat file. I wanted to send the header with the URL. How can I send the header with it?
#ECHO OFF
SET BROWSER=firefox.exe
SET WAIT_TIME = 2
START %BROWSER% -new-tab
"http://localhost/warmup/api/Event/eventsLoc/17.4575262/78.373212/1221"
#ping 127.0.0.1 -n %WAIT_TIME% -W 1000 > nul
pause
please help.

I would advise you to use cURL instead of Firefox.
It is designed for command line so :
you can run it silently (without opening a window)
there are much more options for the command line, such as specifying the HTTP call method (GET, POST, PUT...) and as you required the header.
example from the doc
curl --header "Destination: http://nowhere" http://example.com

Related

NiFi- how to http post a PDF document

I wanted to use NiFi's posthttp/invokeHttp processor to post a PDF to an API.
But considering the following cURL request to replicate in NiFi:
curl -X POST "http://ipaddress:port/api/" -H "accept: application/json" -H
"Content-Type: multipart/form-data" -F "pdf_file=#sample.pdf;
type=application/pdf"
Which property takes the -F information in nifi attributes?
Configuration for invokehttp right now:
error:
"400 Bad Request: The browser (or proxy) sent a request that this server could not understand."
Configration for posthttp right now:
error:
server logs: readv() failed (104: Connection reset by peer) while reading upstream
In older version of nifi you will have to use your own script to build a multipart request and then use invoke to create post request. You can refer to this post for a ExecuteGroovyScript example.
https://stackoverflow.com/a/57204862
Since Nifi 1.12 you can directly use invokeHTTP by setting content-type
https://stackoverflow.com/a/69284300
When you use PostHttp/InvokeHttp you wouldn't be referencing an external file, you would be sending the content of the flow file. So you would first need to bring sample.pdf into NiFi by using GetFile or ListFile/FetchFile and then flow file coming out of those processors represents the PDF, and you would route that flow file to InvokeHttp which would POST the content of the flow file (the pdf).

Marklogic API LATEST/Search? documents Mulitpart/mixed

I want to use a GET URL to search and return a group of documents from MarkLogic API.
If I use a POST method I can set the Accpets:multipart/mixed header and return what I want. The environment I am using can only send GET URL.
How do I either add multipart/mixed to GET URL or how do I pass to MarkLogic API return documents.
The argument view=none returns an error
REST-UNSUPPORTEDPARAM: (err:FOER0000) Endpoint does not support query parameter: Can use the 'none' value for the 'view' parameter only with multipart/mixed accept
You indicate that you accept multipart/mixed by setting the Accept request header.
For example, with cURL:
curl --anyauth --user user:password -X GET -i \
-H "Accept: multipart/mixed; boundary=BOUNDARY" \
'http://localhost:8000/LATEST/search?view=none'
If you are trying to issue a GET search request from your browser with view=none, simply typing in the URL and hitting return may not work.
However, you can still make it work. For example, in FireFox you can:
Pop open the developer toolbar
Select the request
Under the "headers" tab, to the right of the status code, click the "edit and resend" button
In the Request Headers textarea, add "Accept: multipart/mixed; boundary=BOUNDARY"
Click the "Send" button
Select the newly issued request, click the "Response" tab to view your multipart response

Wget cant download file but browser can

I have an url like
http:\/\/23.246.50.145\/?o=AQFsBQ9SB1l-S4Ch0gw3lM0zSs4ReWo3_PsOqoF35YR0eHrAqxQ7GIRonzVp_nrrJ4m9cKer-YAmV-rgYJXHJ1NE9JjLqf78Jp7l9Y-z2njJVV2CpXDAPNoh91iqrDA2vRuNdlvYbbSJ4Sj5Mp-xiegEeAKXnQ&v=3&e=1494051078&t=XUSkPrEHFE2Tas3F9KxR7CPINPI
If i type this url in a browser it starts downloading a file that will named just download Which is actually a music file so i just rename it to .mp4
If I try to use wget it wont work
wget "http:\/\/23.246.50.145\/?o=AQFsBQ9SB1l- S4Ch0gw3lM0zSs4ReWo3_PsOqoF35YR0eHrAqxQ7GIRonzVp_nrrJ4m9cKer-YAmV-rgYJXHJ1NE9JjLqf78Jp7l9Y-z2njJVV2CpXDAPNoh91iqrDA2vRuNdlvYbbSJ4Sj5Mp-xiegEeAKXnQ&v=3&e=1494051078&t=XUSkPrEHFE2Tas3F9KxR7CPINPI"
Will get this error
--2017-05-04 09:10:51-- http://23.246.50.145/?o=AQFsBQ9SB1l-S4Ch0gw3lM0zSs4ReWo3_PsOqoF35YR0eHrAqxQ7GIRonzVp_nrrJ4m9cKer-YAmV-rgYJXHJ1NE9JjLqf78Jp7l9Y-z2njJVV2CpXDAPNoh91iqrDA2vRuNdlvYbbSJ4Sj5Mp-xiegEeAKXnQ&v=3&e=1494051078&t=XUSkPrEHFE2Tas3F9KxR7CPINPI
Connecting to 23.246.50.145:80... connected.
HTTP request sent, awaiting response... 420
2017-05-04 09:10:51 ERROR 420: (no description).
Why is this error?
I got forbidden. You must use ' instead of "
like
wget -d 'http://23.246.50.145/?o=AQFsBQ9SB1l-S4Ch0gw3lM0zSs4ReWo3_PsOqoF35YR0eHrAqxQ7GIRonzVp_nrrJ4m9cKer-YAmV-rgYJXHJ1NE9JjLqf78Jp7l9Y-z2njJVV2CpXDAPNoh91iqrDA2vRuNdlvYbbSJ4Sj5Mp-xiegEeAKXnQ&v=3&e=1494051078&t=XUSkPrEHFE2Tas3F9KxR7CPINPI'

Can I set multiple headers with Siege?

I want to use siege to target a number of URLs on my app, each with different headers. I can set headers for one request
siege -u http://localhost/xyz -d1 -r1000 -c25 --header="Token: f2840fc1"
(this appears to be undocumented)
I can specify a list of URLs in the URL file, with custom headers for each URL. But I can't see a way in the docs.
I suggest using two concurrent calls to siege. Write a URL file that uses Header-A, and another for Header-B.
For my API testing, I've got a get_urls.txt file and post_json_urls.txt file, which I call on two instances of Siege at once. This way one gets called with Content-Type: text/json and the other doesn't. Short of rewriting the Siege url parser, this is the only way I know to do it.
For example:
siege -f get_urls.txt & siege -H 'Content-Type: text/json' -f post_json_urls.txt
As far as I can see from the man page and reading around I think you are right. The only way to specify headers is on the command line using the -H --header options not in the URL file.
You can try this example siege --concurrent=5 --reps=100 --header='sdk:3.0, config:3.0,zid:0' 'https://google.com/api/REGME POST uid=a8qn&aid=43ZK0'

autobench on HTTPS endpoint

How do I set in autobench that I'm testing an HTTPS (port 443) URL?
When I call it with:
autobench --single_host --host1 host.com --port1 443 --uri1 /hello --num_conn 1000 --timeout 5 --low_rate 10 --high_rate 50 --rate_step 10 --num_call 10 --quiet --file results.tsv
it shows:
httperf.parse_status_line: invalid status line `<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'!!
httperf.parse_status_line: bad status 1
Which is not correct because that HTTPS page (in the example above would be https://host.com/hello) returns a valid 200 OK response.
Thanks
You need to add the following line to your ~/.autobench.conf file:
httperf_ssl = NULL
--ssl is a command-line argument of httperf, which autobench calls underneath. The NULL value means to not pass a value for that arg to httperf.
Generally speaking, you can add any additional command-line arguments to httperf by putting them in the config file and prepending them with httperf_. Another example:
httperf_add-header = "Authorization: Basic Zm9vOmJhcg=="
is equivalent to running httperf --add-header "Authorization: Basic Zm9vOmJhcg=="