Tandem - Is there an equivalent to cURL in HP NonStop? - hp-nonstop

I need to execute a simple HTTP POST to a URL from the NonStop computer to make sure a service functions correctly. Is there a way to do this?

Use the built-in TACL commands to make an HTTP POST request. The TACL command POST allows you to send an HTTP POST request to a specified URL. For example:
POST url headers=content-type:text/plain
data=This is the request body

Related

CSRF Token error when attempting to post from CURL to an API endpoint I control. How do I write the request?

I have not utilized this part of Django before, but I have an endpoint which is giving me a 403 error and is telling me that my request needs a csrf token. I was trying to figure out how best to get this since I was attempting to set up a bunch of curl requests to handle some simple queries to the endpoint. Likewise, I was thinking to also use POSTman, but I was not sure where documentation is to handle these request.
I have seen the cookie csrftoken, but when I was attempting to curl with it, it was still giving me a 403. thought it would looking something like this:
curl -d #profilepicturev2.png -b "csrftoken=Ebfn2OlfhSwFjAEQdoQon7wUjbynFoJqrtHMNPla3cy7ZfCMT9cxZ3OQHsbaedam" http://127.0.0.1:8000/api/files/uploader
Maybe I am mistaken? I am trying to send a photo to the server, so i was thinking that this would be correct and wasnt sure if i needed to add additional params in order to append additional data information.
i need to see your code, but i think you need to install "pillow" to send pictures in django !

POST request to Django DRF call working in cURL but not with Postman

I'm following the instructions to support TokenAuthentication in my rest-api site, shown here. Using cURL, I have been able to obtain my user's token (username - example, password - example), through the following command:
curl -X POST -d "username=example&password=example" localhost:8000/api/login/
This returns a successful response, with example's authentication token.
Yet when I do (what I think is) the same thing through Postman, it simply does not work. See image below.
From the error code (400 - Bad request), it seems like it's not even receiving the POST parameters at all. Can anyone help me here?
See your URL in postman. There is attached query String with the URL.So remove that query String from the URL and send parameters as a post request like this.
http://localhost:8000/api/login/
Even this is very old question, but if this answer would be helpful...
I had exactly same issue
solution:
don't put username and password in address bar,but only
and in body put json data of your username and password as below
be careful, don't use single quotation marks'', but use double quotation marks "" instead, otherwise will fail, no clue why
Depending on how your API is set up, you probably need to specify the content type in your request headers, Content-Type: application/json.

How to send POST variable in POSTMAN

I can't get POSTMAN to send any post variables to my Django app. Suppose I have a post variable called 'report_request' and it has a value that is a JSON string. On the Django side I want to get request.POST['report_request'] and parse the JSON into a dictionary. But POSTMAN never seems to send the POST data. How exactly do I do this? Is there some magical header I need to send?
Doh! My bad. The URL I need to connect to is really HTTPS rather than HTTP, but I was specifying the URL as http://. Apparently if Postman is asked to connect to an HTTPS site using HTTP, it silently just drops all POST variables. How lovely. Anyway it was an easy fix, just change the http:// url to https:// and all is well.
Be sure to provide the POST data in the body (body tab) of the request and not in the parameters (params tab).
Otherwise, POSTMAN will interpret your POST request as being without data and on a url with GET parameters.
See these specifications about csrf if needed
Check if you're sending the csrf token, it's a security feature.
https://docs.djangoproject.com/en/1.8/ref/csrf/

How to http post with an empty body request using WS API in Playframework 2 / Scala?

I try to send an HTTP POST request to a service endpoint using Play2/Scala WS API. Since there is no parameters to be sent in the HTTP POST body, how can I send it using
WS.url("http://service/endpoint").post()
I have tried post() without argument but it gave me an error.
Cannot write an instance of Unit to HTTP response. Try to define a
Writeable[Unit]
Can you please help on this ?
thanks in advance...
Since post awaits a value that implements the Writeable and ContentTypeOf type classes,
you can use the Results.EmptyContent from play.api.mvc. (See API)
So I guess
WS.url("http://service/endpoint").post(Results.EmptyContent())
should do. (Didnt test)
For Play 2.6 and after, you have to use play.api.libs.ws.EmptyBody.
import play.api.libs.ws.{EmptyBody, WSClient}
WS.url("http://service/endpoint").post(EmptyBody)
Typical error is:
Cannot find an instance of play.api.mvc.Results.EmptyContent to WSBody. Define a BodyWritable[play.api.mvc.Results.EmptyContent] or extend play.api.libs.ws.ahc.DefaultBodyWritables
As of Play 2.8, you cannot use the WSRequest.post(body) methods with an empty body, because the BodyWritable trait requires a non-empty Content-Type
Instead, you can do ws.url(u).execute("POST") to send an HTTP POST request with no body.

How post data over https with urllib2?

I want to integrate a credit card processing in my website using Paybox.com API's.
I have to send a POST request (using urllib2) to Paybox API's with credit card details (number, date, cvv) when a user submit a form.
How can I secure that? is it enougth to put https://www.mywebsite.com/card/processing in my form action?
How can I send POST data over HTTPS using urllib2?
PS: I work on Django.
Well in terms of security refer to this QA: POST data encryption - Is HTTPS enough?
As far as how to do it, here's an explanation about using urllib: http://www.codercaste.com/2009/11/28/how-to-use-the-urllib-python-library-to-fetch-url-data-and-more/
The idea is to use the urlencode command to create a parameters object for the request, then create a request object from the url and the parameters object, and then call urlopen on the request object in order to actually send the request.
Here are solutions using python-request lib: http://www.python-requests.org/en/latest/user/advanced/
request using ssl: http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification
request using post: http://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests (should also allow verify=True parameter)
By the way, python-request is a very powerful and easy way to make requests.