xPath of JSON response in soapUI - json

can anyone help in finding xpath of 'tenantId' which is in JSON response given below
{
"statusCode": "200",
"errorParams": null,
"payLoad": {
"UGX:XCD": {
"id": 42802,
"fromCurrency": {
"tenantId": "2a610af6-2e42-4a78-8e04-98755e2c6113",
"code": "UGX",
"name": "Ugandan Shilling",
"isoCode": "UGX",
"active": true,
"enabled": true,
"flagModifiedName": false,
"erpId": null,
"createdOn": 1427155200000,
"fieldLibraryStatus": "DRAFT",
"userId": null
},
"toCurrency": {
"tenantId": "2a610af6-2e42-4a78-8e04-98755e2c6113",
"code": "XCD",
"name": "East Caribbean Dollar",
"isoCode": "XCD",
"active": true,
"enabled": true,
"flagModifiedName": true,
"erpId": null,
"createdOn": 1427155200000,
"fieldLibraryStatus": "DRAFT",
"userId": "c7f68b05-044d-44e1-8fc5-0f97a4ece91b"
},
"rate": 33,
"inverseRate": 0.0303,
"createdOn": 1434025926983,
"modifiedOn": 1434326400000,
"active": true,
"purpose": "cmd",
"enabled": true,
"tenantFlag": true,
"erpId": null
}
How to traverse till 'tenantId' ??
Thanks in Advance.

SoapUI internally converts almost anything to XML. You will have to use the ResponseAsXml property. In the GUI, if you click on the XML tab, you can see this representation.
Something like the following should work:
${test_step#ResponseAsXml#//*:fromCurrency/*:tenantId}
${test_step#ResponseAsXml#//*:toCurrency/*:tenantId}

If you want to handle this using groovy, then extend SOAPUI with GSON.jar library provided by Google.
this library specially written to handle the JSON objects.
With this you can rip every individual objects and its attribute-values easily how complex may the JSON object be, a nice add-on to work with.

Related

Custom Approval ActionIdType AWS

I am trying to build a custom approval step for my CodePipeline on AWS. The AWS built default approval ActionTypeId does not let you output artifacts. I want my approval step to be able to output artifacts. I found this document on creating custom ActionTypeIds but I am still confused an fuzzy on this. Any help will be really appreciated.
I've posted the code from AWS. can someone help me understand the "settings" and the "configurationProperties" sections?
{
"category": "Approval",
"provider": "My-Custom-ActionIdType",
"version": "1",
"settings": {
"entityUrlTemplate": "https://my-build-instance/job/{Config:CGBoyProject}/",
"executionUrlTemplate": "https://my-build-instance/job/{Config:ProjectName}/lastSuccessfulBuild/{ExternalExecutionId}/"
},
"configurationProperties": [{
"name": "ProjectName",
"required": true,
"key": true,
"secret": false,
"queryable": false,
"description": "The name of the build project must be provided when this action is added to the pipeline.",
"type": "String"
}],
"inputArtifactDetails": {
"maximumCount": integer,
"minimumCount": integer
},
"outputArtifactDetails": {
"maximumCount": integer,
"minimumCount": integer
},
"tags": [{
"key": "Project",
"value": "ProjectA"
}]
}

Why is JSON being detected as empty?

So I have a JSON file I got from Postman which is returning as an empty object. This is how I'm reading it.
import regscooter from './json_files/reginald_griffin_scooter.json'
const scoot = regscooter;
const CustomerPage = () => {...}
reginald_griffin_scooter.json
{
"success": true,
"result": {
"id": "hhhhhhhhhh",
"model": "V1 Scooter",
"name": "hhhhhhhhhh",
"status": "active",
"availabilityStatus": "not-available",
"availabilityTrackingOn": true,
"serial": "hhhhhhhhhhhh",
"createdByUser": "hhhhhhhhK",
"createdByUsername": "hhhhhhhh",
"subAssets": [
"F0lOjWBAnG"
],
"parts": [
"hhhhhhhh"
],
"assignedCustomers": [
"hhhhhhhhh"
],
"createdAt": "2019-12-03T21:47:26.218Z",
"updatedAt": "2020-06-26T22:05:54.526Z",
"customFieldsAsset": [
{
"id": "hhhhhhh",
"name": "MAC",
"value": "hhhhhhhh",
"asset": "hhhhhhhhhh",
"user": "hhhhhhhhh",
"createdAt": "2019-12-03T21:47:26.342Z",
"updatedAt": "2019-12-11T16:29:24.732Z"
},
{
"id": "hhhhhhhh",
"name": "IMEI",
"value": "hhhhhhh",
"asset": "hhhhhhh",
"user": "hhhhhhhhhh",
"createdAt": "2019-12-03T21:47:26.342Z",
"updatedAt": "2019-12-11T16:29:24.834Z"
},
{
"id": "hhhhhhhhh",
"name": "Key Number",
"value": "NA",
"asset": "hhhhhhhhh",
"user": "hhhhhhhhhhh",
"createdAt": "2019-12-03T21:47:26.342Z",
"updatedAt": "2019-12-11T16:29:24.911Z"
}
]
}
}
The error is that "const scoot" is being shown as an empty object {}. I made sure to save a ton of times everywhere. I am able to read through the imported JSON file in other variables in similar ways, so I don't know why I can't parse this one. I just want to access the JSON object inside this. Also I omitted some information with hhhhh because of confidentiality.
EDIT: The code works, but it still has a red line beneath result when I do:
const scoot = regscooter.result.id;
It would be much more effective if you will provide an example in codesandbox or so.
However at first look it might be a parser issue ( maybe you are using Webpack with missing configuration for parsing files with json extension ), meaning we need more information to provide you with a full answer ( maybe solution ? ).
Have you tried to do the next:
const scoot = require('./json_files/reginald_griffin_scooter.json');

How to add inline image by Microsoft Graph API?

Background
When I use Outlook client to send a mail with inline image.
The image in html email looks like this, which has cid:
<img size="100" src="cid:3bb599fc-f3eb-465b-af83-aa6a495f563a" style="max-width:100%">
When I use
GET /me/messages/{messageId}/attachments
The contentId in the result returned matched the cid in html.
{
"value": [
{
"#odata.type": "#microsoft.graph.fileAttachment",
"id": "aaa",
"lastModifiedDateTime": "2017-11-30T09:32:09Z",
"name": "image.png",
"contentType": "image/png",
"size": 100,
"isInline": true,
"contentId": "3bb599fc-f3eb-465b-af83-aa6a495f563a",
"contentLocation": null,
"contentBytes": "validBase64Bytes"
}
]
}
Using Microsoft Graph API
Now I am trying to use Microsoft Graph API to add inline image.
POST /me/messages/{messageId}/attachments
{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "1.jpg",
"isInline": true,
"contentBytes": "validBase64Bytes"
}
However, the contentId is null in the result returned.
{
"#odata.type": "#microsoft.graph.fileAttachment",
"id": "aaa",
"lastModifiedDateTime": "2017-11-30T09:35:50Z",
"name": "1.jpg",
"contentType": "image/jpeg",
"size": 100,
"isInline": true,
"contentId": null,
"contentLocation": null,
"contentBytes": "validBase64Bytes"
}
And if I set contentId manually in POST
POST /me/messages/{messageId}/attachments
{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "1.jpg",
"isInline": true,
"contentId": "myContentId",
"contentBytes": "validBase64Bytes"
}
It will return the error
{
"error": {
"code": "BadRequest",
"message": "Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.",
"innerError": {
"request-id": "36e95f0a-ad75-46c6-b86c-d585a150b96d",
"date": "2017-11-30T09:37:41"
}
}
}
So how to add inline image correctly?
Weird, I tried to run the exact same code again, it won't give me any error now.
POST /me/messages/{messageId}/attachments
{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "1.jpg",
"isInline": true,
"contentId": "myContentId",
"contentBytes": "validBase64Bytes"
}
Not sure whether it is a temporary issue. I will inform Microsoft team to check the log.
If I am wrong for how to use the API, please definitely point out. Thanks.
I will leave it here for future people to save some time to implement adding inline image.

Getting the value of an image field in Plone 3.x with FSS

I'm trying to migrate an old Plone 3.3 site that uses
FileSystemStorage using Mikko's Simple JSON export script.
Everything runs fine, except for the absence of a value on the image fields, which are returned as empty strings (''):
[
...
{
"allowDiscussion": false,
"contributors": [],
"creation_date": "2009-11-04T15:15:36-02:00",
"creators": [
"johndoe"
],
"description": "",
"effectiveDate": null,
"excludeFromNav": false,
"expirationDate": null,
"id": "banner_vertical.jpg",
"image": "",
"language": "",
"location": "",
"modification_date": "2009-11-04T15:15:37-02:00",
"portal_type": "Image",
"relatedItems": [],
"rights": "",
"subject": [],
"title": "Banner vertical",
"urlLegend": "http://"
},
...
]
Any hint?
(iw.fss version used is 2.8.0rc5).
FSS was not known or used by the site for which the script has been made.
You might want to retrofit convert() and other methods to support your use case.

Returning data from parsed xml to JSON

I am attempting to display some data from JSON that contains parsed XML, in an angular application, and I am stuck.
I can extract the other fields like so {{object.articleId}}. How can I extract child data from the content object? For example, if I need to extract the "default-locale"? I would like to be able to do {{object.content.default-locale}} but this is not working obviously.
[
{
"articleId": "393800",
"classNameId": 0,
"classPK": 0,
"companyId": 10157,
"content": "{\"root\":{\"default-locale\":\"en_US\",\"dynamic-element\":[{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"content\":\"[\\\"General News\\\"]\",\"language-id\":\"en_US\"},\"name\":\"Top_News\",\"type\":\"radio\"},{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"content\":\"_All\",\"language-id\":\"en_US\"},\"name\":\"Location\",\"type\":\"list\"},{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"content\":\"CTC\",\"language-id\":\"en_US\"},\"name\":\"Business_Unit\",\"type\":\"list\"},{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"content\":\"hfhfahfcaf;\",\"language-id\":\"en_US\"},\"name\":\"Subtitle\",\"type\":\"text\"},{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"content\":\"dhfhfowejfwkfpw\",\"language-id\":\"en_US\"},\"name\":\"Intro_Text\",\"type\":\"text\"},{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"content\":\"1430697600000\",\"language-id\":\"en_US\"},\"name\":\"News_Date\",\"type\":\"ddm-date\"},{\"index\":0,\"index-type\":\"\",\"dynamic-content\":{\"content\":\"/image/journal/article?img_id=393803&t=1430750130449\",\"id\":393803,\"language-id\":\"en_US\"},\"name\":\"News_Image\",\"type\":\"image\"},{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"content\":\"flkdsjfldsjffa\",\"language-id\":\"en_US\"},\"name\":\"Freeform\",\"type\":\"text_area\"},{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"content\":\"test\",\"language-id\":\"en_US\"},\"name\":\"News_Tag_1\",\"type\":\"text\"},{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"language-id\":\"en_US\"},\"name\":\"News_Tag_2\",\"type\":\"text\"},{\"index\":0,\"index-type\":\"keyword\",\"dynamic-content\":{\"language-id\":\"en_US\"},\"name\":\"News_Tag_3\",\"type\":\"text\"}],\"available-locales\":\"en_US\"}}",
"createDate": 1430750130000,
"description": "",
"descriptionCurrentValue": "",
"displayDate": 1430749860000,
"expirationDate": 1430836418000,
"folderId": 236650,
"groupId": 10184,
"id": 393801,
"indexable": true,
"layoutUuid": "",
"modifiedDate": 1430836418000,
"resourcePrimKey": 393802,
"reviewDate": null,
"smallImage": false,
"smallImageId": 393804,
"smallImageURL": "",
"status": 3,
"statusByUserId": 10439,
"statusByUserName": "Admin",
"statusDate": 1430836418000,
"structureId": "236652",
"templateId": "236654",
"title": "<?xml version='1.0' encoding='UTF-8'?><root available-locales=\"en_US\" default-locale=\"en_US\"><Title language-id=\"en_US\">Test</Title></root>",
"titleCurrentValue": "Test",
"treePath": "/236650/",
"type": "general",
"urlTitle": "test",
"userId": 10439,
"userName": "Admin",
"uuid": "f06c946e-6efb-4a28-81f3-2a78e1a20814",
"version": 1.0
}
]
Thanks in advance for your assistance
content is actually a json string.
You need to loop over that data when you receive it and set:
object.content = angular.fromJson(object.content);
Perhaps this could be also cleaned up at source if you control the api that is sending it