How to retrieve data from response body when using trigger URL - runscope

I am using trigger URL to run a test case created on Runscope. In response I am getting only details as shown in Runscope documentation. For eg.
Response Sample data:
{
"data": [],
"error": null,
"meta": {"status": "success"}
}
But I need the data in response body retrieved from server for request made.For eg.
{
"Status": "OK",
"Body": [{"userId": 12345,"sessionId": "abcd:1234"}]
}
I am using HttpRequest and HttpResponse for the same.

Why don't you use something like this :
https://www.npmjs.com/package/dyson#installation
It is used to mock results via api .

Related

Azure JSON subprotocol `json.webpubsub.azure.v1`to join a group fetch responses programmatically

I'm trying obtain programmatically if joining the group was successfully when using json.webpubsub.azure.v1 subprotocol to join a group with a sample.
My sample JSON below, which doesn't fetch outcome success response or error response:
Basically, I'm trying to identify if joining the group was successful with the json.webpubsub.azure.v1 subprotocol.
Sample request:
{
"type": "joinGroup",
"group": "group1",
}
Yes, you can, by add “ackId” when joining the group. When the request payload contains “ackId”, the service will return an ack response to the client containing the result for this action. Make sure you use incremental “ackId”s when sending different messages.
Sample request:
{
"type": "joinGroup",
"group": "group1",
"ackId" : 1
}
Sample success response:
{
"type": "ack",
"success": true,
"ackId" : 1
}
Sample error response:
{
"type": "ack",
"success": false,
"ackId" : 1,
"error":
{
"name": "Forbidden",
"description": "The client does not have permission to join group ‘group1’"
}
}

Keep getting Twilio error message 90100 on execution, but results are working

I'm not a programmer so please forgive me. But I've spent hours and hours of research on the topic of collecting information with Twilio AutoPilot and posted that data to Airtable, which I will then have Zapier do some things with that data. I finally had a breakthrough today and am now able to post data from a call or text to Airtable. The only way I got the ending to work was to send the call or text to Studio to finish up the call. Everything seems to work from the end user standpoint, but I'm getting an error 90100 from Twilio. I'm sure I'm just missing one line of code for this to work, and I'm at the end of my rope.
{
"actions": [
{
"say": "Okay lets get you a new appointment. I just need you to answer a few questions."
},
{
"collect": {
"name": "member",
"questions": [
{
"question": "Please tell me your first name.",
"name": "name",
"type": "Twilio.FIRST_NAME"
},
{
"question": "Thanks, and what is your email address?",
"name": "email",
"type": "Twilio.EMAIL"
}
],
"on_complete": {
"redirect": "task://complete_booking"
}
}
}
]
}
Then i have another task setup to redirect to the Twilio Function. This is probably overkill, but it's what I found in research.
{
"actions": [
{
"redirect": {
"method": "POST",
"uri": "https://TWILIO_FUNCTION_URL/atable_post"
}
}
]
}
Then the function is as follows. Mind you, this is posting correctly to airtable.
exports.handler = function(context, event, callback) {
let memory = JSON.parse(event.Memory);
let name = memory.twilio.collected_data.member.answers.name.answer;
let email = memory.twilio.collected_data.member.answers.email.answer;
console.log(memory);
let member = {
name : memory.twilio.collected_data.member.answers.name.answer,
email : memory.twilio.collected_data.member.answers.email.answer,
date : Date.now()
};
var Airtable = require("airtable");
var base = new Airtable({apikey: context.AIRTABLE_API_KEY}).base("AIRTABLE_ID");
base("Members1").create(member, function(err, record) {
if (err) { console.error(err); return; }
console.log(record.getId());
callback(null, member);
});
};
The call hung up at this point, so I redirected it to a Studio Flow, which does work and the call finishes with the response I'm give it before ending the call. Again, everything is working fine, but I get the following error from twilio, and I have no idea how to resolve it.
Invalid Autopilot Actions JSON: Invalid Autopilot Action
Any help would be greatly appreciated. Thanks!
Nice work James! It looks the the issue is the redirect to your Twilio Function is not returning the expected JSON Action response to execute.
Autopilot - Redirect
https://www.twilio.com/docs/autopilot/actions/redirect
Redirecting to URLs When redirecting to a URL, Redirect will make an
HTTP callback to your application and will expect an Autopilot Actions
JSON as a response. The request will contain all the dialogue
information. This is an example of a dynamic Action since the JSON is
rendered dynamically with a URL or your own endpoint.
Can you modify the Twilio Function to return valid Action JSON to Autopilot which sets the returned data, if needed via the Remember action which you can access from Studio?

How to send push notification from Rest API

I have created my App in Firebase and configured for cloud messaging.
When I am sending the notification from Firebase Console, device gets the notification but if I try to send via Rest API (Using PostMan).
Then notification not coming to device but the response is showing as Success.
Here is my PostMan request
URI - https://fcm.googleapis.com/fcm/send
Header: Content-Type:application/json Authorization:key=MY_SERVER_KEY
Body: { "data": { "title": "Firebase", "detail": "I am firebase" },
"to" : "MY FCM TOKEN HERE" }
Response : {
"multicast_id": 7834540847388366233,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1532422122326299%ebf5f25ef9fd7ecd"
}
] }
I have searched and it seems the way mentioned in documentation is same as I am following
Can anyone let me know why it is not working?
Thanks
I am posting here so as to guide others. As per the guidance of #rv7284, We need to send the data in notification key rather any other key.
So While requesting the body should look like this, Other request parameter like header and all will be same as mentioned in the question.
{ "notification": {
"title": "Firebase",
"detail": "I am firebase"
},
"to" : "YOUR FCM TOKEN"
}

Date-time format in the JIRA REST API giving error response Operation value must be a string

I am passing the below JOSN with the POST request to create the Jira issue. One of the parameters is the starting date and time (customfield_10603
).On the JIRA app we have date and time picker for this field.
In what format this value should be sent out. I tried with 2018-06-17T00:00:00.0+0000.
JSON sent:
{
"fields": {
"project":
{
"key": "HOA"
},
"summary": "Test ticket for JIRA_Jenkins integration.",
"customfield_10616":{"value":"Other"},
"description": "Creating of an issue using project keys and issue type names using the REST API",
"customfield_10603": {"value":"2018-06-17T00:00:00.0+0000"},
"issuetype": {"name": "Change Request" },
"customfield_10624": {"value":"Low"},
"customfield_12100": {"value" :"Low"},
"customfield_10625": {"value":"SRE"},
"customfield_10615": {"value":"Routine"}
}
}
received response:
{
"errorMessages": [],
"errors": {
"customfield_10603": "Operation value must be a string"
}
}
Found the solution.
"customfield_10603": "2018-06-17T00:00:00.0+0000".

RestClient undefined method `delete_if' for #<String:0x4b699a8>

OK so, I'm using RestClient and sending this:
{"x_select_params":["account.*"],"domain":"thedomain"}
Via
response = RestClient.get servername, #payload
And I get
undefined method `delete_if' for #<String:0x4b699a8>
In response.
I know that the request is good as it works fine when I use the Chrome rest client extension, I'm thinking that RestClient is having an issue in parsing the response, which is supposed to look like this:
{
"user": {
"id": 4035,
"first_name": "Chris",
"last_name": "Penta",
"status": "PENDING",
"domain": "thedomain",
"default_account_id": 111315004004010,
"primary_alias_id": 131090,
"accounts": [
{
"id": 111315004004010,
"urn": "111315004004010",
"balance": 0,
"status": 0,
"currency_code": 840
}
]
}
}
Is this a bug in RestClient that needs patching? And if so, anyone know how to fix?
Thanks...Chris
I found this error when the headers were in a json format. They needed to be a hash to work.

Resources