SoapUI: Transfer Response Payload Value to New Request (Different Test Steps) - properties

I'm trying to figure out SoapUI, and so far it's been a great tool. However, I cannot figure out this transferring of property stuff. I've read so much and just can't seem to find the answer I'm looking for.
I have one request: TC01_vorbereitenKunde
I receive the following Response Payload back:
HTTP/1.1 200 OK
X-Powered-By: Servlet/3.0
SOAPAction: "http://..."
Accept: text/xml
Content-Type: text/xml; charset=UTF-8
Content-Language: en-US
Date: Tue, 22 Sep 2015 15:58:01 GMT
Content-Length: 414
Content-Encoding: gzip
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<nova-kunden:vorbereitenKundeResponse xmlns:nova-kunden="http://...>
<nova-kunden:vorbereitungKundeAntwort>
<status>true</status>
<tkid>31f64d0f-b076-4304-95ab-15cb0de38adb</tkid>
<meldungen/>
</nova-kunden:vorbereitungKundeAntwort>
</nova-kunden:vorbereitenKundeResponse>
</soapenv:Body>
I then want to take the "tkid" value and place it in the following request: TC02_offeriereLeistungen
I've tried: ${TC01_vorbereitenKunde#Response#//tkid}
"TC01_vorbereitenKunde" is the name of the Test Step where the response payload is from to no avail.
What am I missing? Thank you so much in advance for your help!

Have script assertion for the first step as given below:
import com.eviware.soapui.support.XmlHolder
def xml = new XmlHolder(context.response)
def responseValue = xml.getNodeValue("//*:tkid")
assert null != responseValue, "Response does not have value"
context.testCase.setPropertyValue('TK_ID', responseValue)
In the second step, use ${#TestCase#TK_ID} where value is needed.

Related

VS Code REST Client Extension: How to access nested response headers

I'm trying to access 'nested' headers with the REST Client extension for VS Code.
I defined a GET CSRF_Token request that stores the "Set-Cookie" header inside a #token_response variable.
However the header looks like this:
'csrftoken=aGHuGkRbApH3qAksHHR3uaOKG0eZsYne; expires=Wed, 22 Nov 2023 08:40:05 GMT; Max-Age=31449600; Path=/; SameSite=Lax'
I already tried to access it with something like:
#csrf_token = {{token_response.0.split(';').0.split('=').1}}
and
#csrf_token = {{token_response.//[0].//split(';')[0].//split('=')[1]}}
But this does not seem to be the correct syntax.
Also the documentation does not contain any hints on that yet, sadly.
Now my question is:
Is there a way to only extract the part of the header that contains the value of the "csrftoken" key?
And if so, how?
Here is my code:
# Get CSRF Token
# #name getToken
GET http://{{host}}/api/csrf_token
#token_response = {{getToken.response.headers.Set-Cookie}}
#csrf_token = {{token_response}}
######
# Edit existing xyz
PATCH http://{{host}}/api/xyz/1
content-type: application/json
x-csrftoken: {{csrf_token}}
origin: http://{{host}}
{
"name": "some name"
}
Thanks a lot in advance! :)

Agoda rest api issue.. unable to get response from agoda api

i am trying to get the hotel lists from the agoda api.. but always end up with this :
The request's Content-Type is not supported. Expected:
application/xml or text/xml or application/json
In postman: Set the headers like this first-
then set the body under raw(json)-
You should get the response like this on send-

Telegram Bot API: getChatMember throws USER_ID_INVALID for valid user

I'm trying to find out if a specific User is present in a supergroup, in order to keep track of those who left.
For that, I'm calling the Bot API method getChatMember for each User and checking if their status is either Left or Kicked. However, I noticed that (recently?) I'm getting USER_ID_INVALID errors for many valid users that are either in the supergroup or have been in the past and then left. I also confirmed that those accounts are still active on Telegram.
Here's the HTTP request I'm sending:
POST https://api.telegram.org/botXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXX/getChatMember HTTP/1.1
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8
Content-Length: 46
Host: api.telegram.org
{"chat_id":-0000000000000,"user_id":000000000}
And here's the response I'm getting:
HTTP/1.1 400 Bad Request
Server: nginx/1.12.2
Date: Fri, 20 Apr 2018 04:17:32 GMT
Content-Type: application/json
Content-Length: 74
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Length,Content-Type,Date,Server,Connection
{"ok":false,"error_code":400,"description":"Bad Request: USER_ID_INVALID"}
Any way I look at it, it looks like a perfectly valid request to me. And I haven't been able to find a common pattern between the users that throw this error.
What am I missing here?
EDIT: As #sean pointed out, having one of those users message the bot privately fixed the error for that particular user. But I'm absolutely sure that user was seen before because that's how I got his user ID. What could have caused the bot "forget" about him and how would I prevent this from happening in the future?
This error means your bot haven't seen this user before.
For instance, my user ID is 109780439, you can try getChatMember with #PublicTestGroup, it should response with 400 error.
And then, forward ANY of my message (e.g., this) to your bot, you will see the different result :)
You will create a variable who get your channel's result, like this:
$join : api.telegram.org/botYOURTOKEN/getchat .....
if($message && (strpos($join,'"status":"left"') or strpos($join,'"Bad Request: USER_ID_INVALID"') or strpos($join,'"status":"kicked"'))!== false) {
}

Rails UTF-8 response

I've got a Rails 3.2 app running on Ruby 1.9.3 that returns JSON data stored in a MongoDB database. The data seems to be stored correctly in mongo, e.g. (look at the name attribute):
{ "_id" : ObjectId("4f986cbe4c8086fdc9000002"), "created_at" : ISODate("2012-04-25T21:31:45.474Z"), "updated_at" : ISODate("2012-04-26T22:07:23.901Z"), "creator_id" : ObjectId("4f6b4d3c4c80864381000001"), "updater_id" : null, "name" : "Trädgår'n", "sort" : "tradgarn", "address" : "Nya Allén 11", "coordinates" : [ 11.9764791, 57.7045625 ], "phone" : "46031102080", "url" : "http://www.profilrestauranger.se/tradgarn/", "user_ids" : [ ] }
But when I issue a request that returns this record, I get something like this back (now look at the name attribute):
{"address":"Nya All\u00e9n 11","coordinates":[11.9764791,57.7045625],"created_at":"2012-04-25T23:31:45+02:00","id":"4f986cbe4c8086fdc9000002","name":"Tr\u00e4dg\u00e5r'n","phone":"46031102080","sort":"tradgarn","updated_at":"2012-04-27T00:07:23+02:00","url":"http://www.profilrestauranger.se/tradgarn/"}
The response headers for anyone interested:
HTTP/1.1 200 OK
Server: nginx/1.2.0
Date: Thu, 26 Apr 2012 22:41:13 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 909
Connection: keep-alive
Status: 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Max-Age: 1000
Access-Control-Allow-Headers: *,x-requested-with
X-UA-Compatible: IE=Edge
ETag: "d2a95f06bec10d8087c3188280292d3c"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: fdd042568195df279e59affe45bdcd37
X-Runtime: 0.037134
I cannot seem to figure out why or where the encoding is getting messed up? What gives? Help? :)
The issue is indeed one of JSON UTF-8 encoding. The #to_json method is escaping unicode characters. This can be observed by something like:
user.to_json
# => "{\"created_at\":\"2012-04-19T18:48:01Z\",\"email\":\"tr\\u00e4dg\\u00e5r#example.com\",\"id\":10,\"updated_at\":\"2012-04-27T18:37:10Z\"}"
When parsed, however, this is converted back to how you would expect it. It is possible, however, to generate the JSON using JSON.generate, with which the #as_json method can be used, along with any options for the construction. This doesn't escape the unicode. To do such:
JSON.generate(user.as_json)
# => "{\"created_at\":\"2012-04-19T18:48:01Z\",\"email\":\"trädgår#example.com\",\"id\":10,\"updated_at\":\"2012-04-27T18:37:10Z\"}"
Turns out the problem I was seeing was with the gem colorful_json. I was running the JSON thru its CLI utility cjson, and it was messing up the Unicode. I reported the issue and the new version of the gem fixes this.

getting directly only the contents after the first nth character in vb.net

Is there any way we could get directly say the 1000 characters after the first 5000 characters, skipping everything before that after sending in an HTTP request to an HTTPS page using either GET or POST in VB.NET?
The reason why I ask this question is because in one of the webpage I am trying the get through my program, the website is sending response data in chunks with the first chunk containing some javascript garbage that I have no interest in, the only data I care is in the second chunk and
I have no idea how to get the second chunk after receiving the first one since it is within the same HTTP request
It would save some time and Internet traffic if I can skip the first chunk that I do not need.
Is that possible or I am just day dreaming?
Many thanks!
ADDED:
Here is how a typical header of the response I am getting from the webpage I am trying to get:
Date: Mon, 20 Jun 2011 13:21:56 GMT
Set-Cookie: JSESSIONID=1AF1AF9EF936E1CB2FA85B750EDC67C4; Path=****some path******; Secure
Content-Type: text/html; charset=ISO-8859-1
Transfer-Encoding: chunked
Set-Cookie: **********some cookie***************
path=/
Vary: Accept-Encoding, User-Agent
Not sure if that helps, but as you can see, the chunk size is not visible to me, there is no "Trailer" in the header as well.
Fun little problem. Look at RANGE in the following GET request.
GET /file.txt HTTP/1.1
Host: localhost
Range: bytes=5000-6000
Connection: Close
Edit: Found a HTTP example.
Here is an example in PHP. (Sorry I couldn't find any VB.NET examples).