JSON - parse multiple level - json

I am new to JSON and trying to parse multiple levels, but got stuck. I am using the include file called "json2.asp" (link below), which is based on json2.js.
https://github.com/nagaozen/asp-xtreme-evolution/blob/master/lib/axe/classes/Parsers/json2.asp
So, I got to this so far with the code below.
Set jsonObj = JSON.parse("{}")
jsonObj.set "Subject", "Testing Event Creation"
jsonObj.set "Start", "2016-08-30T15:00:00-07:00"
jsonObj.set "StartTimeZone", "Pacific Standard Time"
jsonObj.set "End", "2016-08-30T17:00:00-07:00"
jsonObj.set "StartTimeZone", "Pacific Standard Time"
jsonObj.set "Attendees", array(JSON.parse("{""EmailAddress"": {""Address"":""user1#domain.com"", ""Name"": ""User""},""Type"":""Required""}" ))
And the code above produces this output below:
{
"Subject": "Testing ERP Event 2",
"Start": "2016-08-30T15:00:00-07:00",
"StartTimeZone": "Pacific Standard Time",
"End": "2016-08-30T17:00:00-07:00",
"Attendees": [
{
"EmailAddress": {
"Address": "user1#domain.com",
"Name": "User"
},
"Type": "Required"
}
]
}
Now, I am stuck on adding additional email addresses under "Attendees" like the example below:
{
"Subject": "Testing ERP Event 2",
"Start": "2016-08-30T15:00:00-07:00",
"StartTimeZone": "Pacific Standard Time",
"End": "2016-08-30T17:00:00-07:00",
"Attendees": [
{
"EmailAddress": {
"Address": "user1#domain.com",
"Name": "User1"
},
"Type": "Required"
},
{
"EmailAddress": {
"Address": "user2#domain.com",
"Name": "User2"
},
"Type": "Optional"
},
{
"EmailAddress": {
"Address": "user3#domain.com",
"Name": "User3"
},
"Type": "Required"
}
]
}
I know that I am not doing this correctly. Please show me an efficient way to perform multiple levels using the json2.asp. I tried to set "Attendees" as a separate object so I can add email addresses, but no success.
Thanks in advance.

Related

PayPal JSON format updating order

I know I am close on this, the error messages are getting nicer. Currently, I can call a similar call to update the seller's email no issue via Postman currently, working on updating the amount and associated objects. Something in my request format is off.
Is my breakdown section in the correct location? The amount_breakdown documentation looks like it is on same level as value and currency_code, so does it need to move into that section.
Here's my request JSON via Postman:
[
{
"op": "replace",
"path": "/purchase_units/#reference_id=='default'/amount",
"value": {
"currency_code": "CAD",
"value": "2",
"amount": {
"currency_code": "CAD",
"value": "2",
"breakdown": {
"item_total": {
"currency_code": "CAD",
"value": "2"
},
"tax_total": {
"value": "0",
"currency_code": "CAD"
}
}
},
"items": [
{
"name": "First Product Name",
"description": "Optional descriptive text..",
"unit_amount": {
"currency_code": "CAD",
"value": "2"
},
"tax": {
"value": "0",
"currency_code": "CAD"
},
"quantity": "1"
}
]
}
}
]
RESPONSE:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"field": "/purchase_units/#reference_id=='default'/amount/breakdown/item_total",
"location": "body",
"issue": "ITEM_TOTAL_REQUIRED",
"description": "If item details are specified (items.unit_amount and items.quantity) corresponding amount.breakdown.item_total is required."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "acecd3643c994",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-ITEM_TOTAL_REQUIRED",
"rel": "information_link",
"method": "GET"
}
]
}
Thanks for any help!
Different variations of objects.
I can get the other PATCH operation working no issue but it is much simpler in object structure
There should be no amount key under the /amount path, and the items array does not belong at that /amount path either.

Microsoft Teams Webhook Generating 400 for Adaptive Card

I have a functioning webhook to a Teams channel to which I can successfully post messages. I am now trying to post an adaptive card to the webhook. Using Postman and performing a Post to https://outlook.office.com/webhook/xyz, with Content-Type set to application/json in the header and the following adaptive card set in the body.
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"speak": "Nothing to say.",
"body": [
{
"type": "TextBlock",
"text": "Hello Teams' user"
}
]
}
With this I receive a HTTP 400 Bad Request and Summary or Text is required message. Does anyone know if Teams webhooks support Adaptive Cards yet or if this is an unsupported task currently?
The answer below is now deprecated. Please refer to this answer and this answer.
Webhooks do not yet support Adaptive Cards! We plan to add support for Adaptive Cards shortly after we release them for bots.
I'm using axios to send an Adaptive Card to a Teams Connector and I was getting this same error. In my case, I was able to resolve the issue by wrapping the card as an "attachment" to the message protocol shown in this link (syntax copied here for reference).
https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-adaptive-cards-using-an-incoming-webhook
{
"type":"message",
"attachments":[
{
"contentType":"application/vnd.microsoft.card.adaptive",
"contentUrl":null,
"content":{
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
"type":"AdaptiveCard",
"version":"1.4",
"body":[
{
"type": "TextBlock",
"text": "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)"
}
]
}
}
]
}
By sending the above JSON as the request body (data argument for axios), I successfully got the Adaptive Card to show up in my Teams Channel.
As you can see, the value of "content" is the Adaptive Card structure. The Adaptive Card follows the documented syntax, found here:
https://learn.microsoft.com/en-us/adaptive-cards/authoring-cards/getting-started
https://learn.microsoft.com/en-us/answers/questions/400502/adaptive-cards-with-incoming-webhooks-in-microsoft.html
But ultimately, I found it easier to work with this "Designer" https://www.adaptivecards.io/designer/
which provides a WYSIWYG interface.
I am sending the request to a Connector that I created in Teams by following the instructions found here:
https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook#create-incoming-webhook-1
And now it responds with 200 OK and shows up in the Channel!
For simple use cases POST this to the webhook url:
{
"title": "Action News",
"text": "not **much** happend (markdown)"
}
For advanced use cases try using MessageCard: https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using
Example:
{
"#type": "MessageCard",
"#context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "Larry Bryant created a new task",
"sections": [{
"activityTitle": "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png)Larry Bryant created a new task",
"activitySubtitle": "On Project Tango",
"activityImage": "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
"facts": [{
"name": "Assigned to",
"value": "Unassigned"
}, {
"name": "Due date",
"value": "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
}, {
"name": "Status",
"value": "Not started"
}],
"markdown": true
}],
"potentialAction": [{
"#type": "ActionCard",
"name": "Add a comment",
"inputs": [{
"#type": "TextInput",
"id": "comment",
"isMultiline": false,
"title": "Add a comment here for this task"
}],
"actions": [{
"#type": "HttpPOST",
"name": "Add comment",
"target": "http://..."
}]
}, {
"#type": "ActionCard",
"name": "Set due date",
"inputs": [{
"#type": "DateInput",
"id": "dueDate",
"title": "Enter a due date for this task"
}],
"actions": [{
"#type": "HttpPOST",
"name": "Save",
"target": "http://..."
}]
}, {
"#type": "ActionCard",
"name": "Change status",
"inputs": [{
"#type": "MultichoiceInput",
"id": "list",
"title": "Select a status",
"isMultiSelect": "false",
"choices": [{
"display": "In Progress",
"value": "1"
}, {
"display": "Active",
"value": "2"
}, {
"display": "Closed",
"value": "3"
}]
}],
"actions": [{
"#type": "HttpPOST",
"name": "Save",
"target": "http://..."
}]
}]
}
You can actually send your adaptive card body inside the body array of this structure:
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.4",
"body": [
]
}
}
]
}
Reference: Microsoft
Recently I was facing the same issue and was looking for a solution. The good part is MS Teams support adaptive cards now
youtube video to explain how it can be implemented
Github link to track the progress on the issue
I managed to send messages to the Teams channel without any failure.

Getting an API generated in-person signing envelope tracked through Salesforce Connect

I'm using the rest API to create an in person signing session from salesforce. My envelope creation json is like this:
{
"documents": [{
"documentBase64": "'+base64EncodedDocToSign+'",
"documentId": "1",
"fileExtension": "pdf",
"name": "contract.pdf"
}
],
"emailSubject": "Please Sign",
"recipients": {
"inPersonSigners": [{
"email": "some#gsome.com",
"name": "Luis",
"hostEmail": "some#gsome.com",
"hostName": "Luis",
"signerEmail": "other#gother.com",
"signerName": "Charles",
"recipientId": "1",
"tabs": {
"signHereTabs": [{
"anchorString": "s1",
"anchorXOffset": "0",
"anchorYOffset": "0",
"anchorIgnoreIfNotPresent": "false",
"anchorUnits": "inches"
}
]
},
"routingOrder": "1",
"clientUserId": "1000",
"embeddedRecipientStartURL": "SIGN_AT_DOCUSIGN",
}
]
},
"status": "sent"
}
The next step would be for the object to be tracked using Connect. Connect is properly configured for the object and works if I "Sign with Docusign" or use a custom button.
I understand I must change the json to include the DSFSSourceObjectId custom field, with value equal to the Id of the object that is originating the request, but if I try to get a customField in there the json is not properly formatted anymore.
I tried adding the customField like:
...
}
]
},
"customFields": [
{
"Name": "DSFSSourceObjectId",
"Value": "' + objectId + '"
}
],
"status": "sent"
}
Is this viable?
I got this working adding the following to the JSON:
"customFields": {
"textCustomFields": [{
"value": "salesforceId",
"required": "false",
"show": "false",
"name": "DSFSSourceObjectId"
}
]
},

What is meaning of a dataStreamId which looks like derived:com.google.activity.segment:<>:from_sample<-derived:com.google.activity.sample:<>:detailed

I am new to google fit api. I was exploring my own fit account. I find this below data source id in my datasources.
Below is the exact dataSource
{
"dataStreamId": "derived:com.google.activity.segment:com.google.android.gms:OnePlus:ONE A2003:10398c01:from_sample<-derived:com.google.activity.sample:com.google.android.gms:OnePlus:ONE A2003:10398c01:detailed",
"dataStreamName": "from_sample<-derived:com.google.activity.sample:com.google.android.gms:OnePlus:ONE A2003:10398c01:detailed",
"type": "derived",
"dataType": {
"name": "com.google.activity.segment",
"field": [
{
"name": "activity",
"format": "integer"
}
]
},
"device": {
"uid": "10398c01",
"type": "phone",
"version": "",
"model": "ONE A2003",
"manufacturer": "OnePlus"
},
"application": {
"packageName": "com.google.android.gms",
"version": "1"
}
}
What is meaning of a dataStreamId
dataStreamId is a property that includes a unique identifier- a set of numbers. This is your developer project number, and it will be the same for all requests made using that particular developer account. More of that here.

Create DocuSign Envelope with Custom Fields

I am trying to add custom fields at the envelope level via the REST API and cannot get the values to be retained. The custom fields have been defined in the UI and come over in the envelope, but without the value that was assigned. If I add a custom field that was not defined in the UI, then it does not come over at all.
If I add the new custom field in a second call after the envelope is initially created, it will work, but that seems extraneous. What am I doing wrong?
Here is the JSON for creating a new custom field in the envelope:
{
"emailSubject": "Please Print, Complete and Sign Document",
"emailBlurb": "Please print and complete documents and sign on paper. ",
"status": "sent",
"customFields": {"textCustomFields":[{"name":"MyOwnField","required":"true","show":"true","value":"MyValue"}]},
"compositeTemplates": [{
"inlineTemplates": [{
"sequence": "1",
"recipients": {
"signers": [{
"requireSignOnPaper": "true",
"name":"Millard Fillmore",
"email":"dgilbert#firstallied.com",
"recipientId": "1",
"routingOrder": "1"
}]
}
}],
"document":
{
"documentId": "1",
"name": "Corestone Account Application.pdf",
"transformPdfFields": false
}
}]
}
The customFields object needs to be located inside the inlineTemplate object. Try this instead:
{
"emailSubject": "Please Print, Complete and Sign Document",
"emailBlurb": "Please print and complete documents and sign on paper. ",
"status": "sent",
"compositeTemplates": [{
"inlineTemplates": [{
"sequence": "1",
"customFields": {
"textCustomFields": [{
"name": "MyOwnField",
"required": "true",
"show": "true",
"value": "MyValue"
}]
},
"recipients": {
"signers": [{
"requireSignOnPaper": "true",
"name": "Millard Fillmore",
"email": "dgilbert#firstallied.com",
"recipientId": "1",
"routingOrder": "1"
}]
}
}],
"document": {
"documentId": "1",
"name": "Corestone Account Application.pdf",
"transformPdfFields": false
}
}]
}