Soap wsa:To specification at curl command line - bash

How can I compose a curl command line that contains a wsa:To Soap specification for example http://myserver.services.com/Services/ServiceUsers.svc?wsdl?

Well, in the end this is not what I wanted but I managed to achieve my goal. The solution was to use the --data argument followed by the xml request corresponding to the request and in it put the wsa:To header. By example:
curl --location --request POST 'http://myserver.services.com/Services/ServiceUsers.svc' --header 'Content-Type: application/soap+xml; charset=UTF-8' --data '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/"><soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>http://tempuri.org/IServiceUsers/UsersList</wsa:Action><wsa:To>http://myserver.services.com/Services/ServiceUsers.svc</wsa:To></soap:Header><soap:Body><tem:UsersList/></soap:Body></soap:Envelope>'
Thanks to #DingPeng for his help, you may be right about the availability of the .Net framework

Related

postman binary data-type detect and save in laravel request

In postman there is an option to send binary datatype in a api.
I am sending that in a api where but i am unable to detect that binary file in laravel request method.
curl --location --request POST 'http://192.168.*.*/api/v1/contact_us/save' \
--header 'Authorization: Bearer some_key' \
--header 'Content-Type: image/jpeg' \
--data-binary '#/Users/username/Desktop/filename.jpeg'
Above is my curl code generated in postman.
Although i am successfully getting this file when i request in multipart/form-data
I did see a question related to it but it is not the exact case
related question
If the HTTP request payload is purely a file (ie. not from a HTML form) then you can access it in Laravel using:
$request->getContent()

How do I send this multipart/form-data to a Web Service using Genexus?

The Following CUrl works perfectly whenever I test it:
curl --request PUT \
--url https://api.sandbox.URL_HERE/document-analysis/90471702021 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer AUTH_TOKEN' \
--header 'Content-Type: multipart/form-data; boundary=---011000010111000001101001' \
--header 'api-version: 1.0' \
--form documentType=RG \
--form documentSide=FRONT \
--form 'image=data:image/jpeg;name=RG_Front.jpg;base64,/9j/4AAQSkZJRgABAQEAAQABAAD/4Tn0RXhpZgAATU0AKgAAAAgABgALAAIAAAAmAAAIYgESAAMAAAABAAEAAAExAAIAAAAmAAAIiAEyAAIAAAAUAAAIrodpAAQAAAABAAAIwuocAAcAAAgMAAAAVgAAEUYc6gAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8JeLF8wysb6N95+837vqfyr2KvwCwP8VH2ABmkb5RQGx2qNm8zhTj3rk5rH0xImduKSY7UP0NPHFMlXcpHTrWiE9j8eNcuLbT/FWpXcipPi/uC1uyNIANzjHHBIyDjOOKyLW8eOS7gNrCTdRF7O3RiESOLUbZY4IdzF41TcQC2R87bm5bmv0mK4xg4HpSKvvUuTvoP6nT7n5yXf7KPxc1ZZVu/Blg6SzNM6HWwgJBCoC6PvYJGCqqWIGScE1auP2SPi/N5/k6PpzPNGgaS81OKRvMRsrIw2FXO0BeRkjqa/RPb6mk9s5p8zBYOmj88ZP2Q/i2bGZY9G0a3U5aOFdV3m2YjD+QzIfJDDIKgkYPGOtQ/8MY/F545IF0/w9DaTFQYDqLHZGH3MrfJ+8LHGWfeeOMV+ie31PNJt96lTfYr6pTPz7uv2Mfi1eNMGj8OqZFYSTSavcOZN3396mMpg4U4CjGwY4zmP/hhv4pLkJN4XXdsORqFwJBIo4lRxFuRupwDt55Br9BiWVckcD0py4ZfahzYfVKZ8FzfsY/FqaczjVPCkcwiMcbLLKFiJxmRUEITzG6l2UsSeopY/wBjH4sRRzww6l4at02qiqt5clSqjCAAx5GDluSQWJJB6V96YpazUmxfU6Z8Ff8ADC3xDa4eU6p4XVWDYgae6aJCTkFRtyMNlsZxknjHFWY/2IviSm+Qa54dt7qUbJbi3aVfMXn5inlbA4zw6gMvY55r7s/GkxVuTZX1Sl2PhrUv2JfHV7Ggh1Pw3BIhk2SMZ2I3kZY/J8zkKFJbOB0rPuP2F/iDJIZzrvhuKbIPmwrP5seAAuxsZGMYAHGCRz1r70C+9Ky7hg9KmMmxrC0k9j4Mtf2F/HlxZrt8ReGpY2V0fCTbZo2cNsdduOCOowck8mtLUP2KfiJeafZWr+INDuRZktH9pedgWzkM42fvCvG3eW24GMDivuCOBY12rgD2GKk21pqJ4Sk3sfBq/sP/ABNbAl8QeGpAsLQ5LTh3DtmTJCBvn6HBHy8DAqC3/YV+IdtZ+Ql/4R8pZBMIVM4jLjI3Y8v5SVwpweQBmvvnbRirF9Updj4Ot/2JfiVZyWskOq+FxLbAqkpeZmaM/wDLJw0RWVM5P7wMeevTEH/DE/xSEjynUfClxLJKJpWnuLhnmYcqrN5fCA/wJtX2r7320bB/kmkL6nTPgif9hv4kXWm2llc3vhG+jttzo11Lc5Dv98gogwWODkc5HBqoP2FPihHfPdprPhn7Vu3CWSSR9/GDvBhw/wBWyR2r9Atopdop3D6nTPgZf2I/icNJ+wDVvDpt/M4tje3IjEZBzECIw4QHB8sPtz+IPWfB39kbx54F+LWheJ9W1Lw/Np+nzO7x6c8yv5flNGkaIUCBFBGAOeTknivsvb15pjAD+LAHXNTKWg44WnF3Q9felIxTc84xUlZWTO0jf/V5709elFFa9QFooopgMXvT6KKACiiigAooooAKKKKACkHSiikAtFFFCAKKKKYBRRRQAVG1FFSwFX7tPoopIBrULRRR1AdTKKKUtgCnUUUgEXvUUP8AqxRRUMCSiiihbgFFFFNgMqWiinABaKKK2AKKKKACiiigAooooAZJ3qP+9RRWD3Akp9FFVED/2Q=='
The Base64 string above was cut just to fit the comment field, but you get the idea.
I just have to send some info to the endpoint using HTTPClient but got stuck especially because Genexus says that the line is too big when I try to convert the image (1Mb) to a base64 string.
Has anyone gone through that?
It seems that the Web Service is expecting the new "multipart/form-data" instead of the old "application/x-www-form-urlencoded" for uploading files as explained here and the specification section for forms in HTML 4.01 is here. So, going to your question, I think that you can use the AddFile method of the HTTPClient data type (as explained here) to get your client working. Readink the wiki, it says:
In particular, if the content of the HttpClient message is multipart / form-data (given by Content-Type Header), then the AddFile method adds the file as multipart. In this case, the second parameter is needed to indicate the name of the variable that the file represents. Also, you have to necessarily precede your sentence with a header that specifies a specific Content-Type, like this:
&Httpclient.Addheader("Content-Type", !"multipart/form-data")
I say "I think" because I dindn't test myself, you can try and let us know if it works or not.

Not able to extract Json Data in Apache-NiFi

I have written a below POST command and using "HandleHttpRequest" processor to receive the POST request in Apache NiFi
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"employeeDetails":{"empid":"124","empname": "praveen"}}' http://localhost:7002
I am able to receive the json data in "handleHttpRequest" processor as shown below
when I check the list queue I am able to see the json data
HandleHttpProcessor details
But I want to extract empid and check whether empid of my json data is null or not,I tried
"ExtractText","ReplaceText","UpdateAttribute","EvaluateJsonPath" etc Processors to fetch empolyee details but I am unable to do it.
EvaluateJson path details
I am getting "flowfile did not have a valid JSON content" error in EvaluateJsonPath processor
How do I extract empdata and check whether its null or not?
The problem is not related to NiFi. You should post data with CURL like this (change double quote " to single quote ' after -d):
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"employeeDetails":{"empid":"124","empname": "praveen"}}' http://localhost:7002
I have the exact same two processors you have, additionally, I also have a HandleHTTPResponse added so that my curl command exits neatly without sending additional buffer messages that make the EvaluateJSONPath component fail with invalid JSON error (My guess is this could have been your case as well).
HTTP Request Flow
Also as #Behrouz Seyedi mentioned you would need to use a single quote in your command. This is my curl command
curl -v -H "Content-type: application/json" -X POST -d '{"employeeDetails":{"empid":"124","empname": "praveen"}}' http://localhost:7003
This is the screenshot to the EvaluateJSONPath processor.
This is the response of the EvaluateJSONPath
empid

ElasticSearch :content-type header application/x-www-form-urlencoded is not supported

So i had this error after typing this command:
curl -XPUT localhost:9200/_bulk --data-binary #movies_elastic.json, i found an answer here : ElasticSearch - Content-Type header [application/x-www-form-urlencoded] is not supported
that suggested to add -H option but i didn't get where to add it exactly.
Please keep in mind i'm new to ELK.
Thanks.
screenshot from console
Assuming everything else with your command is correct, it's a command line option to curl. Like this:
curl -XPUT localhost:9200/_bulk -H'Content-Type: application/json' --data-binary #movies_elastic.json

How to update a TeamCity build parameter using REST+cURL

I have a configuration parameter called "testing" in one of my build configurations in TeamCity. After taking a look at the TeamCity REST API doc here I could get information about this parameter using the following cURL command line commands on Windows:
(1) curl -X GET -H "Authorization: Basic (...)" http://teamcity:8080/httpAuth/app/rest/buildTypes/id:bt7/parameters
(2) curl -X GET -H "Authorization: Basic (...)" http://teamcity:8080/httpAuth/app/rest/buildTypes/id:bt7/parameters/testing
Response:
(1) <?xml version="1.0" encoding="UTF-8" standalone="yes"?><property name="testing" value="11"/></properties>
(2) 11
But then, when I try to update this "testing" build parameter using the following command, I get an error message:
curl -X PUT -d "1" -H "Authorization: Basic (...)" http://teamcity:8080/httpAuth/app/rest/buildTypes/id:bt7/parameters/testing
Response:
Error has occurred during request processing (Unsupported Media Type).
Error: javax.ws.rs.WebApplicationException
Not supported request. Please check URL, HTTP method and transfered data are correct.
I already successfully use a similar command to update the buildNumberCounter setting of the same build configuration:
curl -X PUT -d "1" -H "Authorization: Basic (...)" http://teamcity:8080/httpAuth/app/rest/buildTypes/id:bt7/settings/buildNumberCounter
That's why I thought I can do the same with a build parameter in a similar way. What am I missing here?
UPDATE:
I managed to update the "testing" build parameter with value "1" using Fiddler. The request I composed had the following content:
Request: PUT
URL: http://teamcity:8080/httpAuth/app/rest/buildTypes/id:bt7/parameters/testing
Request headers: Authorization: Basic (...)
Request body: 1
So the problem with my cURL command above is probably somewhere around the -d "1" option. But where?
UPDATE 2:
I'm not sure if that makes any difference, but I use this cURL build on Windows 7.
Instead of fixing the failing cURL command, as a workaround, we use now Node.js to compose and send the REST request to TeamCity.
The script that needs to be fed to node.exe is as follows:
// Equivalent cURL command:
// curl -X PUT -d "1" -H "Authorization: Basic (...)" http://teamcity:8080/httpAuth/app/rest/buildTypes/id:bt7/parameters/testing
var http = require('http'),
options = {
hostname: 'teamcity',
port: 8080,
path: '/httpAuth/app/rest/buildTypes/id:bt7/parameters/testing',
method: 'PUT',
headers: { 'Authorization': 'Basic (...)' }
},
req;
req = http.request(options, function(res) { });
// write data to request body
req.write('1');
req.end();
Although the workaround works perfectly, I would still like to know what's wrong with the above cURL command?
For parameters that are non-XML like the one you are asking about, just add:
--Header "Content-Type: text/plain"
For parameters that are XML then you'll want to switch that to:
--Header "Content-Type: application/xml"
I was having a hard time figuring this out too but I found the answer. Instead of using -d and -H at the front. Use --data and --header at the end as shown below . I found this in the TeamCity docs buried in a "click to expand" example.
Set build number counter:
curl -v --basic --user <username>:<password> --request PUT http://<teamcity.url>/app/rest/buildTypes/<buildTypeLocator>/settings/buildNumberCounter --data <new number> --header "Content-Type: text/plain"
Set build number format:
curl -v --basic --user <username>:<password> --request PUT http://<teamcity.url>/app/rest/buildTypes/<buildTypeLocator>/settings/buildNumberPattern --data <new format> --header "Content-Type: text/plain"
I guess the REST API expect XML as input, add
-H "Content-type:text/xml"
and put XML as input. If you have a XML file file.xml :
curl -d "#/path/to/file.xml" -H "Content-type:text/xml" (...)

Resources