How to extract a substring value from Json response in SOAPUI - groovy

I am trying to fetch the requestID from the message which is a string.
{
"version": "1.0.0-80",
"status": 201,
"error": "MSG004",
"uuid": "aae1bb59-da3f-4118-a4a4-asdfsdfsd",
"message": "Successfully created a request with an id of 1234",
"path": "/api/request/",
"timestamp": "2019-03-21T09:41:58.484"
}
Can anyone help me with creating a property from message, I only need to pass request id in the end of this sentence:
"Successfully created a request with an id of 1234"
Thanks

Using a straight-forward substring should do the trick.
def id = variableThatContainsTheString.substring(46)
This however is not pretty. But nor is the solution you are testing.
I would argue that if the ID is something that should be used by the consumer of the webservice, then it really should be delivered in a key-value of its own. There should be no need to cut it from a string.
The response could then be something like this:
{
"version": "1.0.0-80",
"status": 201,
"error": "MSG004",
"uuid": "aae1bb59-da3f-4118-a4a4-asdfsdfsd",
"message": "Successfully created a request with an id of 1234",
"path": "/api/request/",
"timestamp": "2019-03-21T09:41:58.484",
"id": "1234"
}
Tell the developers to get their act together. ;-)

Related

Why does clangd respond with "method not found" when using textDocument/didOpen?

I try to communicate with clangd. The first initialization is fine, but when trying to open a document with "textDocument/didOpen" i get the response "method not found". I cannot find any other method in the specification for opening documents. Is it the wrong method, or am I doing something else wrong?
My request
Content-Length: 1771
{
"id": 2,
"jsonrpc": "2.0",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"languageId": "cpp",
"text": "file content...",
"uri": "file://src/main.cpp",
"version": 1
}
}
}
The response I get:
Content-Length: 77
{
"error": {
"code": -32601,
"message": "method not found"
},
"id": 2,
"jsonrpc": "2.0"
}
The language server protocol distinguishes between request messages which are client --> server messages to which the server will respond, and notification messages which are client --> server messages which are meant to notify the server about something and do not require a response.
The id field is only expected for request messages (it's used to associate the response with the request). However, textDocument/didOpen is a notification message. Removing the id field should fix the error.
Further reading:
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage

Azure Cognitive Services - Batch Transcription API responds with error message "The recording URI is invalid."

Steps Followed:
I created a speech services instance in West US.
I have the right headers(Content-Type and Ocp-Apim-Subscription-Key)
I make a POST request to https://westus.cris.ai/api/speechtotext/v2.0/transcriptions/ with below request payload
{
"recordingsUrl": "https://transcribehm97c1.blob.core.windows.net/audio-files/2019-04-04_Blockchain%20explained%20with%20TruStory%27s%20Preethi%20Kasireddy.mp3?st=2019-05-27T12%3A19%3A27Z&se=2019-12-31T12%3A19%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=HFBvGl1pmCM95MNU9U3yniMNXrUMT6RmPb36F32cxrY%3D",
"models": [],
"locale": "en-US",
"name": "I dont know why this is not working",
"description": "Someone please send help",
"properties": {
"ProfanityFilterMode": "Masked",
"PunctuationMode": "DictatedAndAutomatic"
}
}
I get a “202 Accepted” response with below headers. This confirms that the request body is valid.
location: https://westus.cris.ai/api/speechtotext/v2.0/transcriptions/69b7abf4-6383-4490-88a9-9fd42a77e470
When I make a GET Request to the above location, I see this
{
"recordingsUrl": "https://transcribehm97c1.blob.core.windows.net/audio-files/2019-04-04_Blockchain explained with TruStory's Preethi Kasireddy.mp3?st=2019-05-27T12:19:27Z&se=2019-12-31T12:19:00Z&sp=rl&sv=2018-03-28&sr=b&sig=HFBvGl1pmCM95MNU9U3yniMNXrUMT6RmPb36F32cxrY%3D",
"resultsUrls": {},
"models": [“I have removed this for brevity”],
"statusMessage": "The recordings URI is invalid.",
"id": "69b7abf4-6383-4490-88a9-9fd42a77e470",
"createdDateTime": "2019-05-27T12:43:39Z",
"lastActionDateTime": "2019-05-27T12:43:50Z",
"status": "Failed",
"locale": "en-US",
"name": "I dont know why this is not working",
"description": "Someone please send help",
"properties": {
"ProfanityFilterMode": "Masked",
"PunctuationMode": "DictatedAndAutomatic"
}
}
The transcriptions fails for some URL's while passing for others for blobs in the same storage although they are all valid URL’s. The SAS URI in the request is valid till end of the
year.
I have re-tried the same request multiple times via code and Postman and it fails.
Link to Swagger Page : https://westus.cris.ai/swagger/ui/index
The issue may be due to the audio file size. Please refer the core features for REST API as the REST support only short Audio.

ElasticSearch illegal_argument_exception for client.bulk() Node.js

I try to send data to ES and I was using POST request to send data line by line and it worked fine with small files.
When I changed to use client.bulk(), I keep getting the following error message:
"status": 400,
"error":
{
"type": "mapper_parsing_exception",
"reason": "failed to parse [target_status_code]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "For input string: \"-\""
}
}
I noticed that after I use bulk, the type of target_status_code field has changed from string to number and many keyord fields are gone.
I only modified the sending request function so I don't understand why it doesn't work when using bulk.

Dialogflow Not able to use Parameter in response

I am trying to use Dialogflow, and following their guide building-your-first-agent to create an intent with response
However, if I use the parameter inside the response, it will return 'not available' from default response. Does anyone know why it is happening?
From the picture, it will response the correct sentence without parameter. the response is not available when using parameter.
Diagnostic info
without parameter
{
"id": "aa316e0a-7f41-46cb-a03c-03c13d80ae6b",
"timestamp": "2018-05-16T18:31:11.858Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "turn on asdkasjd",
"action": "",
"actionIncomplete": false,
"parameters": {
"cameraName": ""
},
"contexts": [],
"metadata": {
"intentId": "41b046bc-65ea-425b-8a33-9e37c44dddf4",
"webhookUsed": "false",
"webhookForSlotFillingUsed": "false",
"intentName": "opencamera"
},
"fulfillment": {
"speech": "Sorry I don't know",
"messages": [
{
"type": 0,
"speech": "OK. I will try to turn on"
}
]
},
"score": 0.9300000071525574
},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "e488d71a-a21e-4cf0-bfcb-13b4a36fd811"
}
The problem is that you're using the #sys:given-name parameter in an attempt to match "camera" or "camera two", but neither of these are a "given name", which is meant to match the name given to a person (as opposed to their family name), not the name given to a device.
In these cases, it is using some rough matching and determining that "turn on" matches enough of the sample phrase to match the Intent, but that there is no value that matches the name part of it. Since that parameter isn't required, the Intent matches without a value for the parameter.
There are a few things you can do to remedy this, depending on your exact needs:
You may wish to mark the parameter as required. (This doesn't solve the name issue, but will make sure it is either matched or the user is prompted for the value.)
You can use the #sys:any entity type. This should match anything the user includes for the parameter.
If you have some defined names, you can define your own entity type.
First, I think you have not added any phrases in 'Training Phrases' section above 'Action and Parameters' section. Please add those to train your agent to detect 'cameraName' parameter from phrases. Secondly, if you see your json, result->parameters->cameraName is empty. And if the parameter is empty, it cannot respond with a response that requires the parameter 'cameraName'. Try adding a third response under responses with parameters that does not uses parameter and see the result, it will return the third response and when it will detect the parameter, it will start showing response with the parameter.

Outlook Mail REST API: send message with attachment

I'm trying to use next API method: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessages. Sending messages without attachments works just fine, but I can not understand how to send message with attachments.
According to docs, Message structure can contain array of Attachments with items of type https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesFileAttachment . Problem is in the field ContentBytes -- it is impossible to dump bytes to JSON before sending request to this API method (actually dumping any BLOB to JSON is nonsense).
How should I pass Attachments using REST API at all?
Thanks.
There's an example of passing the attachment on that page: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessageOnTheFly
I know I'm 3 years late but, you can look at this example:
https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#create-and-send-messages (if you don't get forwarded to the section "Create and send messages", please scroll manually).
I know it is 365 and not Microsoft Graph but request is absolutely same.
This is basically how JSON representation of the post method looks:
https://outlook.office.com/api/v2.0/me/sendmail
{
"Message":
{
"Subject": "Meet for lunch?",
"Body": {
"ContentType": "Text",
"Content": "The new cafeteria is open."
},
"ToRecipients": [
{
"EmailAddress": {
"Address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}
],
"Attachments": [
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt",
"ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
]
}
}

Resources