Request Url:
https://api.convergepay.com/VirtualMerchant/processxml.do
Here is my Sample Xml Request:
xmldata=<txn>
<ssl_merchant_id>my_merchant_id</ssl_merchant_id>
<ssl_user_id>my_user_id</ssl_user_id>
<ssl_pin>my_pin</ssl_pin>
<ssl_transaction_type>ccsale</ssl_transaction_type><ssl_card_number>4000000000000002</ssl_card_number>
<ssl_exp_ date>1124</ssl_exp_date>
<ssl_amount>1.00</ssl_amount>
<ssl_cvv2cvc2_indicator>1</ssl_cvv2cvc2_indicator>
<ssl_cvv2cvc2>786</ssl_cvv2cvc2>
<ssl_first_name>adolfo</ssl_first_name></txn>
</txn>
My Result:
<?xml version="1.0" encoding="UTF-8"?>
<txn>
<errorCode>6042</errorCode>
<errorName>Invalid Request Format</errorName>
<errorMessage>XML request is not well-formed or request is incomplete.</errorMessage>
</txn>
Example request look like this:
curl -X POST -H 'Content-type: text/xml' -d 'xmldata=<txn><ssl_merchant_id>my_merchant_id</ssl_merchant_id><ssl_user_id>my_user_id</ssl_user_id><ssl_pin>my_pin</ssl_pin><ssl_transaction_type>ccsale</ssl_transaction_type><ssl_card_number>4000000000000002</ssl_card_number><ssl_exp_ date>1124</ssl_exp_date><ssl_amount>1.00</ssl_amount><ssl_cvv2cvc2_indicator>1</ssl_cvv2cvc2_indicator><ssl_cvv2cvc2>786</ssl_cvv2cvc2><ssl_first_name>adolfo</ssl_first_name></txn>' https://api.convergepay.com/VirtualMerchant/processxml.do
what the trouble with my request?
Change your HEADER fields:values to the following:
Content-Type: application/x-www-form-urlencoded
Accept: text/xml
Related
I'm trying to set up an SSL certificate for Kong 2.7 installed in Kubernetes but I am not getting this to work as expected. I tried to follow this guide. Even looking for additional help in discussion .
curl -X POST http://kong-admin:8001/certificates -F "cert=kong.lan.pem" -F "key=kong.lan.key" -F "snis[0]=mydomain.net"
This is my response:
{
"fields": {
"cert": "invalid certificate: x509.new: asn1/a_d2i_fp.c:197:error:0D06B08E:asn1 encoding routines:asn1_d2i_read_bio:not enough data",
"key": "invalid key: pkey.new:load_key: asn1/a_d2i_fp.c:197:error:0D06B08E:asn1 encoding routines:asn1_d2i_read_bio:not enough data"
},
"message": "2 schema violations (cert: invalid certificate: x509.new: asn1/a_d2i_fp.c:197:error:0D06B08E:asn1 encoding routines:asn1_d2i_read_bio:not enough data; key: invalid key: pkey.new:load_key: asn1/a_d2i_fp.c:197:error:0D06B08E:asn1 encoding routines:asn1_d2i_read_bio:not enough data)",
"name": "schema violation",
"code": 2
}
Kong deployed with helm chart:
$ helm repo add kong https://charts.konghq.com
$ helm repo update
$ helm install kong/kong --generate-name --set ingressController.enabled=true --set admin.enabled=True --set admin.http.enabled=True --set ingress.enabled=True --set proxy.ingress.enabled=True --set admin.type=LoadBalancer --set proxy.type=LoadBalancer
Does any of you know how to make this working or how to add tls.crt and tls.key into Kong Deployment?
You just miss the # on the curl command to upload files
curl -X POST http://kong-admin:8001/certificates -F "cert=#kong.lan.pem" -F "key=#kong.lan.key" -F "snis[0]=mydomain.net"
curl -X POST http://localhost:8001/certificates -F "cert=kong.lan.pem" -F "key=kong.lan.key" -F "snis[0]=mydomain.net"
will send
POST /certificates HTTP/1.1
Host: localhost:8001
User-Agent: curl/7.68.0
Accept: */*
Content-Length: 363
Content-Type: multipart/form-data; boundary=------------------------d67ae21b533e5746
--------------------------d67ae21b533e5746
Content-Disposition: form-data; name="cert"
kong.lan.pem
--------------------------d67ae21b533e5746
Content-Disposition: form-data; name="key"
kong.lan.key
--------------------------d67ae21b533e5746
Content-Disposition: form-data; name="snis[0]"
mydomain.net
--------------------------d67ae21b533e5746--
echo "toto" >| kong.lan.pem
curl -X POST http://localhost:8001/certificates -F "cert=#kong.lan.pem" -F "key=kong.lan.key" -F "snis[0]=mydomain.net"
will send
POST /certificates HTTP/1.1
Host: localhost:8001
User-Agent: curl/7.68.0
Accept: */*
Content-Length: 421
Content-Type: multipart/form-data; boundary=------------------------973b3467e461334a
--------------------------973b3467e461334a
Content-Disposition: form-data; name="cert"; filename="kong.lan.pem"
Content-Type: application/octet-stream
toto
--------------------------973b3467e461334a
Content-Disposition: form-data; name="key"
kong.lan.key
--------------------------973b3467e461334a
Content-Disposition: form-data; name="snis[0]"
mydomain.net
--------------------------973b3467e461334a--
I'm trying to use POST methods (Revenue REST API) but I always get the error message "Content-Type not application/json".
The strange is that I'm using their website to test: [https://docs.revenuecat.com/reference#receipts][1]
API TEST (IMAGE)
curl --request POST \
--url https://api.revenuecat.com/v1/receipts \
--header 'Accept: application/json' \
--header 'Authorization: Bearer xxxx' \
--header 'Content-Type: application/json' \
--header 'X-Platform: android' \
--data '
{
"product_id": "xxxx",
"price": 12.9,
"currency": "BRL",
"is_restore": "false",
"app_user_id": "xxxx",
"fetch_token": "xxxxxx"
}
'
Any clues?
I've run the code using CURL and it works. Problem was in revenuecat website.
Their API test page has a bug. It adds an extra Content-Type: application/json
header to the request. You can see it the Metadata tab
Request Headers
Accept: application/json
Content-Type: application/json
X-Platform: stripe
Content-Type: application/json
Authorization: Bearer ********************
User-Agent: ReadMe-API-Explorer
And sends the request with an invalid header (you can check it in your browsers network traffic):
content-type: application/json, application/json
This question already has an answer here:
How to make proper multipart request using Karate when file is in --form?
(1 answer)
Closed 2 years ago.
I want to run this kind of API with karate, but failed.
In this situation, the request params are both the combine of "Query String Parameters" and "From Data"; and the content-type is multipart/form-data.
Have tried many ways, always failed. I have no idea how to combine the request body and get the API request passed.
Pls help, many thanks.
Feature: get lab data list
Background:
* url xcxSaasBaseURL
# * url baseURL
Scenario: get lab data list
Given path "/nda/labprocess/list"
* params {usertoken: '#(token)'}
* multipart field LABIDS = '2fdf2349-0488-463b-93ad-886e649978e8'
When method post
Then status 200
* print "response result:", response
Here is the curl copy exported from chrome:
curl 'http://xcx.sys.saas.biosan.cn/nda/labprocess/list?usertoken=962b3afe2d354edda3fcf3f7e03ff0ea' -H 'Proxy-Connection: keep-alive' -H 'Accept: application/json, text/plain, */*' -H 'Origin: http://172.16.10.33:8090' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36' -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundarybgsYtgWxwfnBKz5f' -H 'Referer: http://172.16.10.33:8090/' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9' --data-binary $'------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="STARTDATE"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="ENDDATE"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="ITEMID"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="QCREAGENTNUM"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="PROCESSNUM"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="INSTRUMENTINFO"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="SRCWAY"\r\n\r\n0\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="PAGENUM"\r\n\r\n1\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="PAGESIZE"\r\n\r\n30\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="LABIDS"\r\n\r\n2fdf2349-0488-463b-93ad-886e649978e8\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f--\r\n' --compressed --insecure
curl 'http://xcx.sys.saas.biosan.cn/nda/labprocess/list?usertoken=962b3afe2d354edda3fcf3f7e03ff0ea' -H 'Proxy-Connection: keep-alive' -H 'Accept: application/json, text/plain, */*' -H 'Origin: http://172.16.10.33:8090' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36' -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundarybgsYtgWxwfnBKz5f' -H 'Referer: http://172.16.10.33:8090/' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9' --data-binary $'------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="STARTDATE"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="ENDDATE"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="ITEMID"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="QCREAGENTNUM"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="PROCESSNUM"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="INSTRUMENTINFO"\r\n\r\n\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="SRCWAY"\r\n\r\n0\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="PAGENUM"\r\n\r\n1\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="PAGESIZE"\r\n\r\n30\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f\r\nContent-Disposition: form-data; name="LABIDS"\r\n\r\n2fdf2349-0488-463b-93ad-886e649978e8\r\n------WebKitFormBoundarybgsYtgWxwfnBKz5f--\r\n' --compressed --insecure
EDIT: based on the cURL you added this is my best guess as to what request you are making, note that you can form the url including query parameter manually instead of using param:
* url 'http://xcx.sys.saas.biosan.cn/nda/labprocess/list?usertoken=962b3afe2d354edda3fcf3f7e03ff0ea'
* multipart field STARTDATE = ''
* multipart field ENDDATE = ''
* multipart field ITEMID = ''
* multipart field QCREAGENTNUM = ''
* multipart field PROCESSNUM = ''
* multipart field INSTRUMENTINFO = ''
* multipart field SRCWAY = '0'
* multipart field PAGENUM = '1'
* multipart field PAGESIZE = '30'
* multipart field LABIDS = '2fdf2349-0488-463b-93ad-886e649978e8'
* method post
The request is failed when I post request an API whose header content-type is 'application/x-www-form-urlencoded; charset=UTF-8' and post body is ' param = { this is a json object} '
The curl request like this, it works.
curl 'http://localhost:7272/Acme/iEhr/PersonSample' -H 'Cookie: ACMETMP=fe35925f-a243-4be9-8e73-60c461ef9bd3; JSESSIONID=47A43F4988F232CC7B53F6CF30B954F6; SESSION=e580c2c7-bf4b-45e6-93fc-de6f79854346' -H 'Origin: http://localhost:7272' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, /; q=0.01' -H 'Referer: http://localhost:7272/route/sampleadd' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data 'param=%7B%22cityid%22%3A%222091afc3-bcd6-46d9-8033-3548ad10933b%22%2C%22areaid%22%3A%222d09f5e5-a07d-445c-9d8a-51eb436699a8%22%2C%22hosid%22%3A%220f226b63-58ad-44d7-bf23-25d0345276e1%22%2C%22deptid%22%3A%2291c176f5-63ca-4b95-87c4-9f311864ff9b%22%2C%22barcode%22%3A%221000000000%22%2C ......' --compressed
it also works with postman request but failed with Karate
Scenario: 样本登记
Given path 'iEhr/PersonSample'
And header Content-type = 'application/x-www-form-urlencoded; charset=UTF-8'
* cookies { JSESSIONID: '#(jsessionID)',SESSION: '#(sessionID)', ACMETMP: '#(acmetmpID)'}
And form fields param = {"cityid":"2091afc3-bcd6-46d9-8033-3548ad10933b","areaid":"2d09f5e5-a07d-445c-9d8a-51eb436699a8","hosid":"0f226b63-58ad-44d7-bf23-25d0345276e1","deptid":"91c176f5-63ca-4b95-87c4-9f311864ff9b","barcode":"1000000000","mothername":"manual-mother1","pregweek":"21", and so on}
When method post
Then status 200
* print response
'And form fields param = {this is a json object}'
this sentence should work but failed for us.
What is my means by karate failed ?
The response code is different compared with Karate, and it is expected result when working with postman.
Postman
the necessary param data
Karate:
18:14:09.437 request:
1 > POST http://localhost:7272/Acme/iEhr/PersonSample
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Content-Length: 899
1 > Content-Type: application/x-www-form-urlencoded; charset=UTF-8
1 > Cookie: ACMETMP=d22c0d9a-b98b-4f6f-9e42-2f9bdffa22c8; JSESSIONID=09268B9F4CA0C15AE3FFB1A26BE424ED; SESSION=2baafdac-38d6-43d0-ac5c-d39e2b29fa48
1 > Host: localhost:7272
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_211)
cityid=2091afc3-bcd6-46d9-8033-3548ad10933b&areaid=2d09f5e5-a07d-445c-9d8a-51eb436699a8&hosid=0f226b63-58ad-44d7-bf23-25d0345276e1&deptid=91c176f5-63ca-4b95-87c4-9f311864ff9b&barcode=1000000000&mothername=manual-mother1&pregweek=21&pregday=1&midentitycard=&birthday=2018-10-01+00%3A00&collectdate=2019-05-15+14%3A38&personsex=1&personweight=4000&address=manual-testaddress1&mobile=15397006044&collectperson=&samplequality=1&borntype=1&linkman=&fidentitycard=&labitem=PHE&sampletype=1&btn=&isfee=0&personremark=&telephone=&bednumber=&labstring=&collectnumber=&freecode=&dhosid=0f226b63-58ad-44d7-bf23-25d0345276e1&reviewtype=&diagnosticstatus=¢erid=bb717701-10de-47ee-b49e-693261c6df22&nowdeptid=07eeec75-079b-4fa9-93cf-c45ddc9a87b9&operator=%E9%BB%84%E5%86%88%E5%B8%82%E5%A6%87%E5%B9%BC%E4%BF%9D%E5%81%A5%E9%99%A2&labitems=PHE&pagecode=sampleadd&modifydetail=%E6%A0%B7%E6%9C%AC%E5%BD%95%E5%85%A5
18:14:09.557 response time in milliseconds: 120.12
1 < 200
1 < Accept-Charset: big5, big5-hkscs, cesu-8, euc-jp, euc-kr, gb18030, gb2312, gbk, ibm-thai ...... and so on
1 < Content-Length: 52
1 < Content-Type: text/plain;charset=UTF-8
1 < Date: Wed, 15 May 2019 10:14:09 GMT
1 < X-Application-Context: Acme.jc.test:dev:7272
[{"code":-90018,"result":"(错误-90018)失败!"}]
Can you try this,
Scenario: 样本登记
Given path 'iEhr/PersonSample'
* cookies { JSESSIONID: '#(jsessionID)',SESSION: '#(sessionID)', ACMETMP: '#(acmetmpID)'}
And def ffParams = {"param" : {"cityid":"2091afc3-bcd6-46d9-8033-3548ad10933b","areaid":"2d09f5e5-a07d-445c-9d8a-51eb436699a8","hosid":"0f226b63-58ad-44d7-bf23-25d0345276e1","deptid":"91c176f5-63ca-4b95-87c4-9f311864ff9b","barcode":"1000000000","mothername":"manual-mother1","pregweek":"21"}}
And form fields ffParams
When method post
Then status 200
* print response
Form fields are by default url-encoded only no need to explicitly mention it in header
And form field param = {"cityid":"2091afc3-bcd6-46d9-8033-3548ad10933b","areaid":"2d09f5e5-a07d-445c-9d8a-51eb436699a8","hosid":"0f226b63-58ad-44d7-bf23-25d0345276e1","deptid":"91c176f5-63ca-4b95-87c4-9f311864ff9b","barcode":"1000000000","mothername":"manual-mother1","pregweek":"21","pregday":"1","midentitycard":"","birthday":"2018-10-01 00:00" ...... and so on }
I changed to this, it works now.
I am misled by the keyword 'param' in karate and the keyword 'param' used by our product code.
I do a simple request to share something on my linkedin profile
I try to just do it with curl but it doesn't work
I set the content-type to JSON in the header and I also set the authorization in the header
curl -v -H 'Authorization: OAuth oauth_consumer_key="V9uKPtEEB7JxQvYzbR2DuDfLe4qXjASgP5UhPJp8k13CYgSnN3BRFILxUJ6ApuCH",oauth_token="d6af5cda-b46e-4c38-b566-11428a9584fc",oauth_signature_method="HMAC-SHA1",oauth_signature="1PofnBExFc7pMB8b08fV34B5sTg%3D",oauth_timestamp="1323544645",oauth_nonce="516e0a1eadda4c24bfbcc4ca5e0cbedc",oauth_version="1.0"' -H 'Content-Type: application/json' -X POST -d '{"recipients":{"values": [{"person":{"_path": "/people/~"}}]}, "subject": "JSON POST test", "body": "You rule"}' http://api.linkedin.com/v1/people/~/shares
When I post this I get this result
About to connect() to api.linkedin.com port 80 (#0)
* Trying 216.52.242.83... connected
* Connected to api.linkedin.com (216.52.242.83) port 80 (#0)
> POST /v1/people/ICshCGDT79/shares HTTP/1.1
> User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
> Host: api.linkedin.com
> Accept: */*
> Authorization: OAuth oauth_consumer_key="V9uKPtEEB7JxQvYzbR2DuDfLe4qXjASgP5UhPJp8k13CYgSnN3BRFILxUJ6ApuCH",oauth_token="d6af5cda-b46e-4c38-b566-11428a9584fc",oauth_signature_method="HMAC-SHA1",oauth_signature="1PofnBExFc7pMB8b08fV34B5sTg%3D",oauth_timestamp="1323544645",oauth_nonce="516e0a1eadda4c24bfbcc4ca5e0cbedc",oauth_version="1.0"
> Content-Type: application/json
> Content-Length: 120
>
< HTTP/1.1 401 Unauthorized
< Server: Apache-Coyote/1.1
< Date: Sat, 10 Dec 2011 19:17:14 GMT
< Vary: *
< x-li-format: xml
< Content-Type: text/xml;charset=UTF-8
< Content-Length: 393
<
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
<status>401</status>
<timestamp>1323544635447</timestamp>
<request-id>9UR4KT2T5Z</request-id>
<error-code>0</error-code>
<message>[unauthorized]. OAU:V9uKPtEEB7JxQvYzbR2DuDfLe4qXjASgP5UhPJp8k13CYgSnN3BRFILxUJ6ApuCH|d6af5cda-b46e-4c38-b566-11428a9584fc|*01|*01:1323544645:1PofnBExFc7pMB8b08fV34B5sTg=</message>
</error>
* Connection #0 to host api.linkedin.com left intact
* Closing connection #0
Anyone can tell me where am I wrong?
Thanks,