Invalid Subelement Phone_ExtensionStr-urn:com.workday/bsvc for element Phone_Information_Data workday - servicenow

I am trying to add a phone number(with phone extension) in the contact details in Workday through REST api.
My phone details object looks like this:
"Phone Details": [
{
"Area_Code": null,
"Country_ISO_Code": null,
"Delete": false,
"Do_Not_Replace_All": true,
"ID": null,
"International_Phone_Code": "1",
"Phone_Device_Type_Reference_ID": "telephone",
"Phone_Extension": 123,
"Phone_Number": "1234567890",
"Phone_Reference_ID": null,
"Usage_Details": [
{
"Comments": null,
"Is_Primary": true,
"Public": true,
"Type_Reference_ID": "Work",
"Use_For_Reference_ID": null,
"Use_For_Tenanted_Reference_ID": null
}
]
}
]
I got an error: Invalid Subelement Phone_ExtensionStr-urn:com.workday/bsvc for element Phone_Information_Data workday
Is there something wrong with the format that i have for my "Phone_Extension"?

Found the issue: Issue is with the script that transformed JSON -> XML, instead of Phone_Extension it is using Phone_ExtensionStr

Related

Validation of each field in JSON response using karate API

I want to validate particular fields in the response whether it is integer or float(ex: fullbathrooms field). I tried below code but getting match failed error. Could you please help here ?.....Thanks
Given path '/property-client'
And request {"address": <address>,"city": <city>,"state": <state>,"zipCode": <zipCode>}
When method post
Then status 200
And print response
And match response == {fullbathrooms:'#number'}
Examples:
|read('testFile1.csv')|
Error : match failed: EQUALS
Actual response:
{
"success": true,
"message": {
"version": "1.0",
"response": {
"id": "94568859",
"type": "express",
"responseheader": null,
"reportdata": {
"property": {
"source": null,
"type": null,
"dom": null,
"propertytype": "Single Family Residence",
"standardtype": null,
"address": {
"documentid": null,
"number": "150",
"directional": null,
"street": "BRIDGE",
"suffix": "RD",
"postdirectional": null,
"unit": "",
"city": "HILLSBOROUGH",
"state": "CA",
"zip": "94010",
"zipplus4": "6908",
"fulladdress": "150 BRIDGE RD, HILLSBOROUGH, CA 94010"
},
"info": {
"type": null,
"fips": "6081",
"county": "San Mateo",
"bedrooms": "5",
"bathrooms": "6.50",
"fullbathrooms": "6.50",
"totalrooms": "0",
"livingarea": "7750",
"totallivingarea": "7750",
"landarea": "41382",
"landareatype": null,
"pool": "true",
"landvalue": "6904800",
"improvementvalue": "3284414",
"assessedvalue": "10189214",
"assessedyear": "2021",
"taxvalue": "11746898",
"taxyear": "2021",
"deliquentyear": null,
"yearbuilt": "2011",
"propertytax": null,
"approxage": "11",
"parcelnumber": "032-400-110",
"titlecompany": null,
"geocode": {
"latitude": "37.563272",
"longitude": "-122.334442",
"geoqualitycode": ""
}
}
Please take some time to read the documentation: https://github.com/karatelabs/karate#match-contains
I'm not going to refer to your response dump (which by the way is not valid JSON), but give you a simple example. Please pay attention to the structure of your JSON. And note that the 6.50 is a string not a number in your response.
* def response = { "foo": { "bar": { "fullbathrooms": "6.50" } } }
* match response.foo.bar == { fullbathrooms: '#string' }
If you want to validate numbers within strings, please refer other answers, for example: https://stackoverflow.com/search?q=%5Bkarate%5D+number+regex

What is the difference between storing data in conversation state property vs context serialization of a dialog

When I was reviewing someone else's code base for a bot framework v4 project, I noticed a lot of state data stored in private members of that particular dialog instance instead of storing it within it's own StateProperty. For instance the developer tried to store data between WaterfallSteps in private members and wanted to consume it in a subsequent step within a new turn (instead of pushing the result with stepContext.Next(result)).
Different to v3 (as soon as I remember), in v4 the dialog itself is not serialized and therefore those private members are "reset" in a new turn.
I saw this "try" with many of my co-workers when they started with bot framework v4 as it feels natural to them.
Thus my question is more out of curiosity and as follows:
As documented here, the bot initializes the dialog subsystem by calling create context on the dialog set, which returns a dialog context. That dialog context contains the necessary information needed by the dialog.
As the DialogSet is initialized with ConversationState, I asked my self what exactly is meant by "the necessary informations". Which informations of the particular dialog instance are actually restored?
Are there any or is it really just the context around a dialog (like waterfall step index) that is restored?
Depending on the response to this question, one could ask why design was chosen to store it with dedicated state properties instead of serializing the dialog instance with its members set, which seems a more natural way for most people I looked over their shoulders.
Why was the behaviour changed between v3 and v4 and what are the top reasons for this?
In both Bot Builder V4 and V3, the DialogStack is stored in state. You are correct that V3 serialized and deserialized dialog fields. However, this 'magic' was often times problematic. The V3 binary serialization method would only allow the sdk to target netframework, and the entire dialog stack was more fragile. The V4 dialog stack was re-architected, and feedback from V3 was incorporated. State is now less automatic, and more 'in the hands of the developer'.
Here is an example of ConversationState containing a DialogStack:
"document": {
"$type": "System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Collections.Concurrent",
"DialogState": {
"$type": "Microsoft.Bot.Builder.Dialogs.DialogState, Microsoft.Bot.Builder.Dialogs",
"DialogStack": {
"$type": "System.Collections.Generic.List`1[[Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs]], System.Private.CoreLib",
"$values": [
{
"$type": "Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs",
"Id": "GreetingDialog",
"State": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"dialogs": {
"$type": "Microsoft.Bot.Builder.Dialogs.DialogState, Microsoft.Bot.Builder.Dialogs",
"DialogStack": {
"$type": "System.Collections.Generic.List`1[[Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs]], System.Private.CoreLib",
"$values": [
{
"$type": "Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs",
"Id": "namePrompt",
"State": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"options": {
"$type": "Microsoft.Bot.Builder.Dialogs.PromptOptions, Microsoft.Bot.Builder.Dialogs",
"Prompt": {
"$type": "Microsoft.Bot.Schema.Activity, Microsoft.Bot.Schema",
"type": "message",
"id": "3Md4r2ECwdEJnnPshesDe1-g|0000009",
"timestamp": null,
"localTimestamp": null,
"localTimezone": null,
"serviceUrl": "https://webchat.botframework.com/",
"channelId": "webchat",
"from": {
"$type": "Microsoft.Bot.Schema.ChannelAccount, Microsoft.Bot.Schema",
"id": "BotHealthTest#6hiZPWXn5jc",
"name": "BotHealthTest",
"aadObjectId": null,
"role": null
},
"conversation": {
"$type": "Microsoft.Bot.Schema.ConversationAccount, Microsoft.Bot.Schema",
"isGroup": null,
"conversationType": null,
"id": "3Md4r2ECwdEJnnPshesDe1-g",
"name": null,
"aadObjectId": null,
"role": null,
"tenantId": null
},
"recipient": {
"$type": "Microsoft.Bot.Schema.ChannelAccount, Microsoft.Bot.Schema",
"id": "EGnHowki8Se",
"name": "You",
"aadObjectId": null,
"role": null
},
"textFormat": null,
"attachmentLayout": null,
"membersAdded": null,
"membersRemoved": null,
"reactionsAdded": null,
"reactionsRemoved": null,
"topicName": null,
"historyDisclosed": null,
"locale": null,
"text": "What is your name?",
"speak": null,
"inputHint": "expectingInput",
"summary": null,
"suggestedActions": null,
"attachments": null,
"entities": null,
"channelData": null,
"action": null,
"replyToId": "3Md4r2ECwdEJnnPshesDe1-g|0000007",
"label": null,
"valueType": null,
"value": null,
"name": null,
"relatesTo": null,
"code": null,
"expiration": null,
"importance": null,
"deliveryMode": null,
"listenFor": null,
"textHighlights": null,
"semanticAction": null
},
"RetryPrompt": null,
"Choices": null,
"Validations": null
},
"state": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib"
}
}
},
{
"$type": "Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs",
"Id": "profileDialog",
"State": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"options": null,
"values": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib"
},
"instanceId": "9b48b35f-3fa5-431d-bb4d-9a512491aca4",
"stepIndex": 1
}
}
]
}
}
}
}
]
}
}
}
That said, Bot Builder Adaptive Dialog follows a model more closely resembling the V3 implementation. Preview bits can be found in this branch: 4.Future Please check it out, and provide feedback on the Github repository.

How can I get the Bot to list/get the participants or members on a group conversation?

I have created a skypeBot that can be added to a group conversation. Is there a way on how the bot can get the list of participants on from the conversation?
There are at least 2 ways to get the participants of a group conversation with a bot in Skype, but you will get their IDs only:
Case 1: By checking the ConversationUpdate message that is raised when creating the conversation.
Sample (made with one of my bots):
{
"type": "conversationUpdate",
"id": "f:6c9b7aa2",
"timestamp": "2017-06-30T11:40:09.3Z",
"localTimestamp": null,
"serviceUrl": "https://smba.trafficmanager.net/apis/",
"channelId": "skype",
"from": {
"id": "29:1AE5BB....",
"name": null
},
"conversation": {
"isGroup": true,
"id": "19:fd3d....#thread.skype",
"name": null
},
"recipient": {
"id": "28:myBotAppId",
"name": "myBotName"
},
"textFormat": null,
"attachmentLayout": null,
"membersAdded": [{
"id": "29:1AE5BB...",
"name": null
}, {
"id": "29:1DwlGVz...",
"name": null
}, {
"id": "28:myBotAppId",
"name": null
}],
"membersRemoved": [],
"topicName": null,
"historyDisclosed": null,
"locale": null,
"text": null,
"speak": null,
"inputHint": null,
"summary": null,
"suggestedActions": null,
"attachments": [],
"entities": [],
"channelData": null,
"action": null,
"replyToId": null,
"value": null,
"name": null,
"relatesTo": null,
"code": null
}
Here you have 2 users that are in the group conversation in the membersAdded block: 29:1AE5BB.... and 29:1DwlGVz.... The last ID is the bot ID
Case 2: by requesting the API.
You can do a GET request to https://smba.trafficmanager.net/apis/v3/conversations/yourConversationId/members and you will get the same 2 IDs.
See also more details here: https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-GetConversationMembers
So from C# code you can do the following:
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
var members = connector.Conversations.GetConversationMembersWithHttpMessagesAsync(activity.Conversation.Id).Result.Body;
For c# you can try this in the messageController
ConnectorClient connector = new ConnectorClient(new System.Uri(activity.ServiceUrl));
var members = connector.Conversations.GetConversationMembersWithHttpMessagesAsync(activity.Conversation.Id).Result.Body;

Laravel Cashier: Resume a single payment

after a successful payment I store the stripe id on a mysql table. With that id I would like to retrieve all the details stored in the stripe database.
So is it possible to resume a single payment by the stripe id?
Thanks
Here is the documentation you need to use: https://stripe.com/docs/api/php#retrieve_customer
Use the "customer retrieve" Stripe API call to retrieve details about the customer's purchase:
Stripe::setApiKey(Config::get('your_stripe_secret_key_here'));
$customer_object = Customer::retrieve(customers_stripe_id);
This will return the following JSON:
Stripe\Customer JSON: {
"id": "cus_7KJZQ8Z6jfSSMl",
"object": "customer",
"account_balance": 0,
"created": 1447172728,
"currency": "usd",
"default_source": "card_175evz2eZvKYlo2CKoS2WEDk",
"delinquent": false,
"description": "Bingo|www|0c1234567890",
"discount": null,
"email": null,
"livemode": false,
"metadata": {
},
"shipping": null,
"sources": {
"object": "list",
"data": [
{
"id": "card_175evz2eZvKYlo2CKoS2WEDk",
"object": "card",
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"customer": "cus_7KJZQ8Z6jfSSMl",
"cvc_check": "pass",
"dynamic_last4": null,
"exp_month": 5,
"exp_year": 2016,
"funding": "credit",
"last4": "4242",
"metadata": {
},
"name": null,
"tokenization_method": null
}
],
"has_more": false,
"total_count": 1,
"url": "/v1/customers/cus_7KJZQ8Z6jfSSMl/sources"
},
"subscriptions": {
"object": "list",
"data": [
],
"has_more": false,
"total_count": 0,
"url": "/v1/customers/cus_7KJZQ8Z6jfSSMl/subscriptions"
}
}
Here is Stripe's version of the API call:
\Stripe\Stripe::setApiKey("your_secret_key");
\Stripe\Customer::retrieve("the_customers_id");
Make sure to import the \Stripe classes by adding this at the top of your Model or Controller:
use Stripe\Customer;
use Stripe\Stripe;
if you want to use "Stripe" instead of \Stripe\Stripe and \Stripe\Customer prefixes)

How can I access elements of a JSON return from a Stripe api call?

I am using ruby and sinatra. After a Stripe API call, I want to access an element, from a JSON return, and put it into my database.
The ruby code is:
require 'sinatra'
require 'stripe'
require 'pg'
require 'sequel'
get '/save_customer' do
customer = Stripe::Customer.retrieve("cus_6EfJSbJ8gCTxxx")
puts customer
last4 = customer["sources"]["data"]["last4"]
DB[:stripe_customers].insert(:user_id=>user_id, :email=>email, :stripe_customer_id=>customer_id, :stripe_customer_card=> last4)
end
The JSON (taken from the API docs, not my return) is as follows:
{
"object": "customer",
"created": 1431570089,
"id": "cus_6EfJSbJ8gCTxxx",
"livemode": false,
"description": "Example customer",
"email": null,
"delinquent": false,
"metadata": {
},
"subscriptions": {
"object": "list",
"total_count": 0,
"has_more": false,
"url": "/v1/customers/cus_6EfJSbJ8gCTMrd/subscriptions",
"data": [
]
},
"discount": null,
"account_balance": 0,
"currency": "usd",
"sources": {
"object": "list",
"total_count": 1,
"has_more": false,
"url": "/v1/customers/cus_6EfJSbJ8gCTMrd/sources",
"data": [
{
"id": "card_162ByRBVd5ndD62KfaONcG4G",
"object": "card",
"last4": "4242",
"brand": "Visa",
"funding": "credit",
"exp_month": 12,
"exp_year": 2018,
"country": "US",
"name": null,
"address_line1": null,
"address_line2": null,
"address_city": null,
"address_state": null,
"address_zip": "123456",
"address_country": null,
"cvc_check": "pass",
"address_line1_check": null,
"address_zip_check": "pass",
"dynamic_last4": null,
"metadata": {
},
"customer": "cus_6EfJSbJ8gCTxxx"
}
I have tried:
last4 = customer[:data][:sources][:last4]
and with "" as above.
The error message has varied, currently TypeError - no implicit conversion of String into Integer. I assume this is because I have not extracted the element I need correctly, or it could mean that the api call did not work but I assume that it did.
Try this:
last4 = customer["sources"]["data"][0]["last4"]

Resources