I have an json output which looks like,
"details": [
{
"id": "",
"name": "",
"status": "",
},
{
"id": "",
"name": "",
"status": "",
},
{
"id": "",
"name": "",
"status": "",
},
{
"id": "",
"name": "",
"status": "",
}
From this output I can iterate values like //jsonObject/details and fetching individual item like
json-eval('$.details.id'), but I want to store all Id's and Name's into a Array in wso2 ESB, from the output I get, Can anyone help me.
Not sure if that helps, I think the following pseydo code might do it but I haven't tried it.
//create an empty var
<property name="newArray" value=""/>
//iterate over the json
<iterate xmlns:ns="http://org.apache.synapse/xsd" continueParent="true" expression="//jsonObjects/object" id="MyIterator">
....
<property name="newArray" expression="fn:concat(get-property('newArray'),//jsonObjects/object/value)" scope="operation"/>
....
</iterate>
<log>
<property name="afterIterate" expression="get-property('operation','newArray')"/>
</log>
Related
https://github.com/intuit/karate/issues/554
I have a multirow JSON, I would like to iterate for each row using Scenario outline
It is working if I call by the row number, i am using a dynamic JSON file
Data.json
[
{
"address": {
"addressLine1": "ttes",
"addressLine2": "Test"
},
"name": {
"firstName": "TEST",
"lastName": "TEST"
},
"phone": {
"phoneExtension": "1234",
"phoneNumber": "999999999"
},
"email": {
"emailAddress": "TEST#TEST.com"
}
},
{
"address": {
"addressLine1": "ttes1",
"addressLine2": "Test1"
},
"name": {
"firstName": "TEST1",
"lastName": "TEST1"
},
"phone": {
"phoneExtension": "1234",
"phoneNumber": "999999999"
},
"email": {
"emailAddress": "TEST#TEST1.com"
}
}]
Working if
Feature: Read from File
Background:
* def Testdata = read('Data.json')
Scenario Outline: [1] Test with multiple records on JSON
Given url_stg
And path 'test','test'
And request Testdata[0]
When method POST
Examples:
|Testdata |
Working for Testdata[0]. I have dynamic json, I am looking for a way to iterate through the json autoamtically.
My request body should be one row from JSON like :
{
"address": {
"addressLine1": "ttes1",
"addressLine2": "Test1",
},
"name": {
"firstName": "TEST1",
"lastName": "TEST1",
},
"phone": {
"phoneExtension": "1234",
"phoneNumber": "999999999",
},
"email": {
"emailAddress": "TEST#TEST1.com"
}
This will be easier in the next version, see this ticket: https://github.com/intuit/karate/issues/717#issuecomment-489339287
So if you can build from source and test that would help.
For now you have to do this:
And request { address: <address>, name: <name>, phone: <phone>, email: <email> }
Hi I have the following object:
{ "name": "Joe", "email": "joe.smith#test.com", "items": [ { "id": "1", "name": "Name 1" }, { "id": "2", "name": "Name 2" }...] }
I need to remove the name property from all the 'items', I have tried using omit but can't seem to get this working:
_.omit(this.user, ["items.name"]);
Any help would be great!
The _.omit() method doesn't work on multiple items in this way. You can use _.map() with _.omit():
const user = { "name": "Joe", "email": "joe.smith#test.com", "items": [ { "id": "1", "name": "Name 1" }, { "id": "2", "name": "Name 2" }] }
const result = {
...user,
items: _.map(user.items, user => _.omit(user, 'name'))
}
console.log(result)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js"></script>
I a using Microsoft Bot Framework and am trying to do a HTTP Post with an image sent to the bot as an attachment. I see a ContentURL in the Attachment object but cannot figure out how to POST the image to my API with RestSharp?
Any Ideas?
There are a couple possibilities here.
First is to send an image as an attachment. Please see this documentation you JSON would look like this:
{
"type": "message",
"from": {
"id": "12345678",
"name": "sender's name"
},
"conversation": {
"id": "abcd1234",
"name": "conversation's name"
},
"recipient": {
"id": "1234abcd",
"name": "recipient's name"
},
"text": "Here's a picture of the duck I was telling you about.",
"attachments": [
{
"contentType": "image/png",
"contentUrl": "http://aka.ms/Fo983c",
"name": "duck-on-a-rock.jpg"
}
],
"replyToId": "5d5cdc723
}
the other possibility is that you could send an image in a card (which has 2 possibilities itself). For this you can see this documentation for rich cards. in this here is an example of the JSON for that
{
"type": "message",
"from": {
"id": "12345678",
"name": "sender's name"
},
"conversation": {
"id": "abcd1234",
"name": "conversation's name"
},
"recipient": {
"id": "1234abcd",
"name": "recipient's name"
},
"attachments": [
{
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"title": "title goes here",
"subtitle": "subtitle goes here",
"text": "descriptive text goes here",
"images": [
{
"url": "http://aka.ms/Fo983c",
"alt": "picture of a duck",
"tap": {
"type": "playAudio",
"value": "url to an audio track of a duck call goes here"
}
}
],
"buttons": [
{
"type": "playAudio",
"title": "Duck Call",
"value": "url to an audio track of a duck call goes here"
},
{
"type": "openUrl",
"title": "Watch Video",
"image": "http://aka.ms/Fo983c",
"value": "url goes here of the duck in flight"
}
]
}
}
],
"replyToId": "5d5cdc723"
}
the second option for cards would be adaptive cards. by using the visualizer you can actually manipulate the JSON and see how it would be rendered in different channels.
I have a Mule flow that calls two REST API's resulting in two json list payloads. I need to obtain a merged json list from these two payloads.
I managed to achieve this with a scatter-gather flow with a custom aggregator strategy. However the code I had to write for this looks rather messy and it's slow.
Is there any way to achieve this using dataweave?`
input Json list 1:
[{
"ID": "1",
"firstName": "JANE""familyName": "DOE",
"Entities": [{
"ID": "515785",
"name": "UNKOWN UNITED",
"callSign": "UU"
}]
},
{
"ID": "2",
"firstName": "JOHN",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "515785",
"name": "UNKOWN UNITED",
"callSign": "UU"
}]
}]
input Json list 2:
[{
"ID": "1",
"firstName": "JANE",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "8916514",
"name": "UNKOWN INCORPORATED",
"callSign": "UI"
}]
},
{
"ID": "4",
"firstName": "JAKE",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "8916514",
"name": "UNKOWN INCORPORATED",
"callSign": "UI"
}]
}]
desired output is a merged list without duplicate IDs:
[{
"ID": "1",
"firstName": "JANE",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "515785",
"name": "UNKOWN UNITED",
"callSign": "UU"
},
{
"Entities_ID": "8916514",
"name": "UNKOWN INCORPORATED",
"callSign": "UI"
}]
},
{
"ID": "2",
"firstName": "JOHN",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "515785",
"name": "UNKOWN UNITED",
"callSign": "UU"
}]
},
{
"ID": "4",
"firstName": "JAKE",
"familyName": "DOE",
"Entities": [{
"Entities_ID": "8916514",
"name": "UNKOWN INCORPORATED",
"callSign": "UI"
}]
}]
This works for me with dataweave where payload is list1 and flowVars.list2 is list2
%dw 1.0
%output application/json
%var mergeddata = flowVars.list2 groupBy $.ID
---
payload map ((data,index) -> {
ID: data.ID,
firstName : data.firstName,
familyName : data.familyName,
Entities : data.Entities ++ (mergeddata[data.ID].Entities default [])
}) ++
(flowVars.list2 filter (not (payload.ID contains $.ID)))
Hope this helps
Using the V2 DocuSign REST API, is it possible to get a list of users who have the "send on behalf of" and "account wide" permission?
Looking through the docs, I see that the Get User List method does not return any permission info. The Get User Information method returns a little more but nothing permission specific, other than a permissionProfileId for each group.
So is it possible to get permission info with user data? Or is there a method I can call using the permissionProfileId to check if a user has those permissions?
What I am ultimately trying to do is get a list of users who are able to use the "Send on behalf of" feature which requires the "send on behalf of" and "account-wide rights" permissions.
You can get a list of all users and their User Settings with below rest method as an DS Admin:
https://demo.docusign.net/restapi/v2/accounts/[accountid]/users/?additional_info=true
Sample output below:
{
"users": [
{
"userName": "DocuSignTest2 User-2",
"userId": "b67aa83b-2b3e-4669-a897-89e44b5724c2",
"userType": "CompanyUser",
"isAdmin": "False",
"userStatus": "Created",
"uri": "/users/b67aa83b-2b3e-4669-a897-89e44b5724c2",
"email": "youremail#yourdoman.com",
"firstName": "DocuSignTest2",
"lastName": "User-2",
"userSettings": [
{
"name": "canManageAccount",
"value": "false"
},
{
"name": "canSendEnvelope",
"value": "true"
},
{
"name": "locale",
"value": "en"
},
{
"name": "canSendAPIRequests",
"value": "false"
},
{
"name": "apiAccountWideAccess",
"value": "false"
},
{
"name": "enableVaulting",
"value": "false"
},
{
"name": "vaultingMode",
"value": "none"
},
{
"name": "enableTransactionPoint",
"value": "true"
},
{
"name": "enableSequentialSigningAPI",
"value": "true"
},
{
"name": "enableSquentialSigningUI",
"value": "true"
},
{
"name": "enableDSPro",
"value": "false"
},
{
"name": "powerFormAdmin",
"value": "false"
},
{
"name": "powerFormUser",
"value": "true"
},
{
"name": "canEditSharedAddressbook",
"value": "use_private_and_shared"
},
{
"name": "canManageTemplates",
"value": "create"
},
{
"name": "enableSignOnPaperOverride",
"value": "false"
},
{
"name": "enableSignerAttachments",
"value": "true"
},
{
"name": "allowSendOnBehalfOf",
"value": "false"
},
{
"name": "allowRecipientLanguageSelection",
"value": "true"
},
{
"name": "selfSignedRecipientEmailDocument",
"value": "include_pdf"
}
],
"sendActivationOnInvalidLogin": "false",
"enableConnectForUser": "false",
"groupList": [
{
"groupId": "128693",
"groupName": "Everyone",
"groupType": "everyoneGroup"
}
],
"workAddress": {
"address1": "",
"address2": "",
"city": "",
"stateOrProvince": "",
"postalCode": "",
"phone": "",
"country": ""
},
"homeAddress": {
"address1": "",
"address2": "",
"city": "",
"stateOrProvince": "",
"postalCode": "",
"phone": "",
"country": ""
}
},
[rest removed for sake of example]
There is not one call that can complete this task.
My recommendation is to put all of these users in a Group and then you can query who is in the group through the API.
Example get list of user's per group:
GET https://{server}.docusign.net/restapi/v2/accounts/{accountId}/groups/{groupId}/users
If you want to audit the group or see who you need to move into the group you can get a list of users and then look at user details per user (loop through programmaticaly).
Example get user settings to check userSettings->allowSendOnBehalfOf :
GET https://{server}.docusign.net/restapi/v2/accounts/{accountId}/users/{userId}