I am trying to configure an API call with an array in Postman, but I'm unable to figure out how to properly configure my parameters so that the Items and Properties appears as they do in the sample below. I can't quite figure out how to next Items > Item > Properties > Property
Here's a screenshot of what I need to send should look like
I feel like I might be getting close, but it's still wrong.
Here's a screenshot of my last attempt
It is possible by Postman Variable and hierarchy JSON access method.
Steps Overview
I will shows simple demo and apply your case.
Simple Demo
Demo - I will show ADD operation in Calculator SOAP
SOAP service URL
http://www.dneonline.com/calculator.asmx
Using variables input_a, input_b for adding
1. Assign Variable
JSON input
var jsonData = {
"key_a" : {
"data" : "2"
},
"key_b": {
"data" : "3"
}
}
input_a = jsonData["key_a"]["data"] = 2
input_b = jsonData["key_b"]["data"] = 3
In Pre-request Script section in Postman
2. Apply XML
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="http://tempuri.org/">
<intA>{{input_a}}</intA>
<intB>{{input_b}}</intB>
</Add>
</soap:Body>
</soap:Envelope>
In input Body section in Postman
3. SOAP/POST Call
In outputBody section in Postman
4. XML Parsing
In Tests section in Postman
var xmlTree = xml2Json(responseBody);
var text = xmlTree["soap:Envelope"]["soap:Body"]["AddResponse"]["AddResult"];
postman.setEnvironmentVariable("output_result", Number(text));
console.log(postman.getEnvironmentVariable("output_result"));
5. Result
output_result = input_a + input_b
5 = 2 + 3
Complicate Demo - your question
Apply in your case by same idea(Simple Demo)
1. Assign Variable at Pre-request Script
var jsonData = {
"username" : "tom",
"password" : "1234",
"subscriptionId" : "sub-125abdv1",
"items": [
{
"item" : {
"id" : "CN #00168927",
"properties" : [
{
"property" : {
"name" : "ssn",
"value" : "555-01-0001",
}
},
{
"property" : {
"name" : "lastName",
"value" : "James",
}
}
]
}
},
{
"item" : {
"id" : "CN #00927119",
"properties" : [
{
"property" : {
"name" : "firstName",
"value" : "Jack",
}
},
{
"property" : {
"name" : "lastName",
"value" : "Doyle",
}
},
{
"property" : {
"name" : "ssn",
"value" : "555-01-0002",
}
}
]
}
}
]
}
console.log("username = " + jsonData["username"]);
console.log("password = " + jsonData["password"]);
console.log("subscriptionId = " + jsonData["subscriptionId"]);
postman.setEnvironmentVariable("username", jsonData["username"]);
postman.setEnvironmentVariable("password", jsonData["password"]);
postman.setEnvironmentVariable("subscriptionId", jsonData["subscriptionId"]);
console.log("items[0] id = " + jsonData["items"][0]["item"]["id"]);
postman.setEnvironmentVariable("item_zero_id", jsonData["items"][0]["item"]["id"]);
console.log("items[0] properties[0] name = " + jsonData["items"][0]["item"]["properties"][0]["property"]["name"]);
postman.setEnvironmentVariable("item_zero_property_zero_name", jsonData["items"][0]["item"]["properties"][0]["property"]["name"]);
console.log("items[0] properties[0] value = " + jsonData["items"][0]["item"]["properties"][0]["property"]["value"]);
postman.setEnvironmentVariable("item_zero_property_zero_value", jsonData["items"][0]["item"]["properties"][0]["property"]["value"]);
console.log("items[0] properties[1] name = " + jsonData["items"][0]["item"]["properties"][1]["property"]["name"]);
postman.setEnvironmentVariable("item_zero_property_one_name", jsonData["items"][0]["item"]["properties"][1]["property"]["name"]);
console.log("items[0] properties[1] value = " + jsonData["items"][0]["item"]["properties"][1]["property"]["value"]);
postman.setEnvironmentVariable("item_zero_property_one_value", jsonData["items"][0]["item"]["properties"][1]["property"]["value"]);
console.log("items[1] id = " + jsonData["items"][1]["item"]["id"]);
postman.setEnvironmentVariable("item_one_id", jsonData["items"][1]["item"]["id"]);
console.log("items[1] properties[0] name = " + jsonData["items"][1]["item"]["properties"][0]["property"]["name"]);
postman.setEnvironmentVariable("item_one_property_zero_name", jsonData["items"][1]["item"]["properties"][0]["property"]["name"]);
console.log("items[1] properties[0] value = " + jsonData["items"][1]["item"]["properties"][0]["property"]["value"]);
postman.setEnvironmentVariable("item_one_property_zero_value", jsonData["items"][1]["item"]["properties"][0]["property"]["value"]);
console.log("items[1] properties[1] name = " + jsonData["items"][1]["item"]["properties"][1]["property"]["name"]);
postman.setEnvironmentVariable("item_one_property_one_name", jsonData["items"][1]["item"]["properties"][1]["property"]["name"]);
console.log("items[1] properties[1] value = " + jsonData["items"][1]["item"]["properties"][1]["property"]["value"]);
postman.setEnvironmentVariable("item_one_property_one_value", jsonData["items"][1]["item"]["properties"][1]["property"]["value"]);
console.log("items[1] properties[2] name = " + jsonData["items"][1]["item"]["properties"][2]["property"]["name"]);
postman.setEnvironmentVariable("item_one_property_two_name", jsonData["items"][1]["item"]["properties"][2]["property"]["name"]);
console.log("items[1] properties[2] value = " + jsonData["items"][1]["item"]["properties"][2]["property"]["value"]);
postman.setEnvironmentVariable("item_one_property_two_value", jsonData["items"][1]["item"]["properties"][2]["property"]["value"]);
2. Apply XML
<?xml version="1.0"?>
<AddPortfolioItemsRequest xmlns="http://www.bkwservice.com/api/2022-08-01">
<username>{{username}}</username>
<password>{{password}}</password>
<subscriptionId>{{subscriptionId}}</subscriptionId>
<items>
<item>
<id>{{item_zero_id}}</id>
<properties>
<property>
<name>{{item_zero_property_zero_name}}</name>
<value>{{item_zero_property_zero_value}}</value>
</property>
<property>
<name>{{item_zero_property_one_name}}</name>
<value>{{item_zero_property_one_value}}</value>
</property>
</properties>
</item>
<item>
<id>{{item_one_id}}</id>
<properties>
<property>
<name>{{item_one_property_zero_name}}</name>
<value>{{item_one_property_zero_value}}</value>
</property>
<property>
<name>{{item_one_property_one_name}}</name>
<value>{{item_one_property_one_value}}</value>
</property>
<property>
<name>{{item_one_property_two_name}}</name>
<value>{{item_one_property_two_value}}</value>
</property>
</properties>
</item>
</items>
</AddPortfolioItemsRequest>
Related
I want to do something like this -
#ApiOperation("Solve for tasks in JSON file")
#PostMapping(value = "/tasks/file",
consumes = {MediaType.MULTIPART_FORM_DATA_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<Plan> solveTest(#RequestBody(value = "file") InputStream filrInputStream) {}
I tried adding jersey multipart dependency in my spring boot app and tried my api method signature as below, but when I try posting my json string I get input stream as empty-
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
#ApiImplicitParams({
#ApiImplicitParam(
name = "file",
dataType = "java.io.InputStream",
examples = #io.swagger.annotations.Example(
value = {
#ExampleProperty(value = "[\r\n"
+ " {\r\n"
+ " \"duration\": 0,\r\n"
+ " \"xxxxxxTG\": \"string\",\r\n"
+ " \"sequence\": 0,\r\n"
+ " \"xxxxxx\": \"string\",\r\n"
+ " \"taskId\": \"string\",\r\n"
+ " \"taskType\": \"string\",\r\n"
+ " \"xcoordinate\": 0,\r\n"
+ " \"ycoordinate\": 0\r\n"
+ " }\r\n"
+ "]", mediaType = "multipart/form-data")
}))
})
#PostMapping(value = "/tasks/file",
consumes = {MediaType.MULTIPART_FORM_DATA_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE}
)
public ResponseEntity<Plan> solveTest1(#FormDataParam("file") InputStream file, #FormDataParam("file") FormDataContentDisposition fileMetaData)
I am Integrating paytm gateway in ios app when I generating checksum through api calling and pass this checksum with below param in web view
WEB VIEW is loading with Parms:
{
"CALLBACK_URL" = "https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=SJ-1552029210215";
"CHANNEL_ID" = WAP;
CHECKSUMHASH = "FRMuR8LLFvg3wkIf6gp4BqVnNigr6WvUaSm9EVJIJo6Z5RicUvU7acRGZlEfK1FGoeNSqN53R0OphttHFnJuZ0lKeAZDvrG7Pr5ZnlzTEUw=";
"CUST_ID" = 64;
EMAIL = "jitu123#gmail.com";
"INDUSTRY_TYPE_ID" = Retail;
MID = rxazcv89315285244163;
"MOBILE_NO" = 566789877;
"ORDER_ID" = "SJ-1552029210215";
"TXN_AMOUNT" = "246.0";
WEBSITE = WEBSTAGING;
}
I am getting back below response
{
"ORDERID" : "SJ-1552029210215",
"MID" : "rxazcv89315285244163",
"TXNAMOUNT" : "246.00",
"BANKTXNID" : "",
"RESPCODE" : "330",
"STATUS" : "TXN_FAILURE",
"CURRENCY" : "INR",
"RESPMSG" : "Paytm checksum mismatch."
}
how can i solve paytm checksum mismatch issue???
i am trying to create an XML file using groovy script. There is a requirement to loop two things, so that the resulting XML includes all the objects as passed by the user.
Here is the code so far, with the first loop:
import groovy.xml.*
//map to loop
def workflows = [[ name: "A", file: "fileA" , objectName: "wf_A" , objectType: "workflow", sourceRepository: "DEV2"],
[ name: 'B' , file: 'fileB' , objectName: 'wf_B' , objectType: 'workflow', sourceRepository: 'DEV2']]
// def folderNameMap = [[ srcFolder: ["srcFolder1", "srcFolder2"], TgtFolder: ["TgtFolder1", "TgtFolder2"]],
// [srcFolder: ["srcFolder3"], TgtFolder: ["TgtFolder3"]]
// ]
def builder = new StreamingMarkupBuilder()
builder.encoding = 'UTF-8'
def xml = builder.bind {
mkp.xmlDeclaration()
'udm.DeploymentPackage'(version:'$BUILD_NUMBER', application: "informaticaApp"){
deployables {
workflows.each { item ->
'powercenter.PowercenterXml'(name:item.name, file:item.file){
scanPlaceholders{ mkp.yield(true) }
sourceRepository{ mkp.yield(item.sourceRepository) }
'folderNameMap' {
entry( key:"multifolder", "{{multifolderTST}}" ) // <- this is hard code and i want to remove this
}
'objectNames' {
value { mkp.yield(item.objectName) }
}
'objectTypes' {
value { mkp.yield(item.objectType) }
}
}
}
}
dependencyResolution{ mkp.yield('LATEST') }
undeployDependencies{ mkp.yield(false) }
}
}
println XmlUtil.serialize(xml)
The resultant XML is:
<?xml version="1.0" encoding="UTF-8"?><udm.DeploymentPackage version="$BUILD_NUMBER" application="informaticaApp">
<deployables>
<powercenter.PowercenterXml name="A" file="fileA">
<scanPlaceholders>true</scanPlaceholders>
<sourceRepository>DEV2</sourceRepository>
<folderNameMap>
<entry key="multifolder">{{multifolderTST}}</entry>
</folderNameMap>
<objectNames>
<value>wf_A</value>
</objectNames>
<objectTypes>
<value>workflow</value>
</objectTypes>
</powercenter.PowercenterXml>
<powercenter.PowercenterXml name="B" file="fileB">
<scanPlaceholders>true</scanPlaceholders>
<sourceRepository>DEV2</sourceRepository>
<folderNameMap>
<entry key="multifolder">{{multifolderTST}}</entry>
</folderNameMap>
<objectNames>
<value>wf_B</value>
</objectNames>
<objectTypes>
<value>workflow</value>
</objectTypes>
</powercenter.PowercenterXml>
</deployables>
<dependencyResolution>LATEST</dependencyResolution>
<undeployDependencies>false</undeployDependencies>
</udm.DeploymentPackage>
This achieves the looping for the map declared as 'workflows' . There is another entry in the XML that needs to be iterated. The section in the script is
'folderNameMap' {
entry( key:"multifolder", "{{multifolderTST}}" ) // <- this is hard code and i want to remove this
}
I need to have this section iterated and create new line entries in the resulting XML, if multiple values were supplied to the script. Like:
<folderNameMap>
<entry key="multifolder">{{multifolderTST}}</entry>
<entry key="multifolder2">{{multifolderTST2}}</entry>
<entry key="multifolder3">{{multifolderTST3}}</entry>
</folderNameMap>
How can i define this 2nd map, so that the resultant XML looks like this: (the foldermap is a map. so i will have cases where only one srcFolder and a tgtFolder was given OR there will be times when there will be multiple srcFolder anb TgtFolders were given.)
<?xml version="1.0" encoding="UTF-8"?><udm.DeploymentPackage version="$BUILD_NUMBER" application="informaticaApp">
<deployables>
<powercenter.PowercenterXml name="A" file="fileA">
<scanPlaceholders>true</scanPlaceholders>
<sourceRepository>DEV2</sourceRepository>
<folderNameMap>
<entry key="multifolder">{{multifolderTST}}</entry>
</folderNameMap>
<objectNames>
<value>wf_A</value>
</objectNames>
<objectTypes>
<value>workflow</value>
</objectTypes>
</powercenter.PowercenterXml>
<powercenter.PowercenterXml name="B" file="fileB">
<scanPlaceholders>true</scanPlaceholders>
<sourceRepository>DEV2</sourceRepository>
<folderNameMap>
<entry key="multifolder1">{{multifolderTST1}}</entry>
<entry key="multifolder2">{{multifolderTST2}}</entry>
<entry key="multifolder3">{{multifolderTST3}}</entry>
</folderNameMap>
<objectNames>
<value>wf_B</value>
</objectNames>
<objectTypes>
<value>workflow</value>
</objectTypes>
</powercenter.PowercenterXml>
</deployables>
<dependencyResolution>LATEST</dependencyResolution>
<undeployDependencies>false</undeployDependencies>
</udm.DeploymentPackage>
So, I'm taking a stab in the dark here (as I'm not 100% sure I know what your question is), but assuming your input list can be changed to:
def workflows = [
[ name: 'A',
file: 'fileA',
objectName: 'wf_A',
objectType: 'workflow',
sourceRepository: 'DEV2',
folderNames: [ multifolder: '{{multifolderTST}}',
multifolder2: '{{multifolderTST2}}' ]],
[ name: 'B',
file: 'fileB',
objectName: 'wf_B',
objectType: 'workflow',
sourceRepository: 'DEV2',
folderNames: [ multifolder3: '{{multifolderTST3}}',
multifolder4: '{{multifolderTST4}}' ]]
]
Then, you can just do:
def builder = new StreamingMarkupBuilder()
builder.encoding = 'UTF-8'
def xml = builder.bind {
mkp.xmlDeclaration()
'udm.DeploymentPackage'(version:'$BUILD_NUMBER', application: "informaticaApp"){
deployables {
workflows.each { item ->
'powercenter.PowercenterXml'(name:item.name, file:item.file) {
scanPlaceholders(true)
sourceRepository(item.sourceRepository)
folderNameMap {
item.folderNames.each { name, value ->
entry(key:name, value)
}
}
objectNames {
value(item.objectName)
}
objectTypes {
value(item.objectType)
}
}
}
}
dependencyResolution('LATEST')
undeployDependencies(false)
}
}
I am indexing text document using Flume, I do not see any error or warning message but data is not getting ingested to Solr Log level for both Solr and Flume is set to TRACE, ALL
Flume version : 1.5.2.2.3
Solr Version : 5.5
**Config files are as below**
**Flume Config :**
agent.sources = SpoolDirSrc
agent.channels = FileChannel
agent.sinks = SolrSink
# Configure Source
agent.sources.SpoolDirSrc.channels = fileChannel agent.sources.SpoolDirSrc.type = spooldir
agent.sources.SpoolDirSrc.spoolDir = /home/flume/source_emails agent.sources.SpoolDirSrc.basenameHeader = true agent.sources.SpoolDirSrc.fileHeader = true
agent.sources.SpoolDirSrc.deserializer =org.apache.flume.sink.solr.morphline.BlobDeserializer$Builder
agent.channels.FileChannel.type = file agent.channels.FileChannel.capacity = 10000
agent.sinks.SolrSink.type = org.apache.flume.sink.solr.morphline.MorphlineSolrSink
agent.sinks.SolrSink.morphlineFile = /etc/flume/conf/morphline.conf agent.sinks.SolrSink.batchsize = 1000 agent.sinks.SolrSink.batchDurationMillis = 2500 agent.sinks.SolrSink.channel = fileChannel agent.sinks.SolrSink.morphlineId = morphline1 agent.sources.SpoolDirSrc.channels = FileChannel agent.sinks.SolrSink.channel = FileChannel
"
Morphline Config
solrLocator: {
collection : gsearch
zkHost : "codesolr-as-r3p:21810,codesolr-as-r3p:21811,codesolr-as-r3p:21812"
}
morphlines :
[
{
id : morphline1
importCommands : ["org.kitesdk.**", "org.apache.solr.**"]
commands :
[
{ detectMimeType { includeDefaultMimeTypes : true } }
{
solrCell {
solrLocator : ${solrLocator}
captureAttr : true
lowernames : true
capture : [_attachment_body, _attachment_mimetype, basename, content, content_encoding, content_type, file, meta]
parsers : [ { parser : org.apache.tika.parser.txt.TXTParser } ]
}
}
{ generateUUID { field : id } }
{ sanitizeUnknownSolrFields { solrLocator : ${solrLocator} } }
{ logDebug { format : "output record: {}", args : ["#{}"] } }
{ loadSolr: { solrLocator : ${solrLocator} } }
]
}
]
Please help me what could be the issue
Regards,
~Sri
Normally en flume logs you can see more detailed of your error, you can paste the trace?
May be morphilines doesnt find your solr configuration, you can add this property in your morphilines.conf
solrHomeDir : "/your_solr_config_files"
I hope it's your help
We have to convert Leads to accounts via REST -OAuth calls. We are able to create, update(Edit) and Detail Lead fields but not able to convert them.
We found the same is possible via SOAP API but we are following REST OAuth only.
Yes and we resolved this by creating an Apex class for REST call. Sample code is this -
#RestResource(urlMapping='/Lead/*')
global with sharing class RestLeadConvert {
#HttpGet
global static String doGet() {
String ret = 'fail';
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String leadId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(leadId);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr ;
try{
lcr = Database.convertLead(lc);
system.debug('*****lcr.isSuccess()'+lcr.isSuccess());
ret = 'ok';
}
catch(exception ex){
system.debug('***NOT CONVERTED**');
}
return ret;
}
}
And you can use this call by
<Your Instance URL>/services/apexrest/Lead/<LeadId>
This test will give you around 93% of coverage.
#isTest
public class RestLeadConvertTest{
static testMethod void testHttpGet() {
Lead l = new Lead();
l.FirstName = 'First';
l.LastName = 'Last';
l.Company = 'Unit Test';
insert l;
Test.startTest();
RestRequest req = new RestRequest();
RestResponse res = new RestResponse();
req.requestURI = '/Lead/' + l.Id;
req.httpMethod = 'GET';
RestContext.request = req;
RestContext.response= res;
RestLeadConvert.doGet();
Test.stopTest();
}
}
You can construct a one-off SOAP request to convert a lead and use the same OAuth token that you already have for the REST API.
The request body should look like:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ens="urn:sobject.partner.soap.sforce.com" xmlns:fns="urn:fault.partner.soap.sforce.com" xmlns:tns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<tns:SessionHeader>
<sessionId>YOUR_OAUTH_TOKEN</sessionId>
</tns:SessionHeader>
</soap:Header>
<soap:Body>
<tns:convertLead>
<tns:leadConverts>
<tns:leadId>YOUR_LEAD_ID</tns:leadId>
<tns:convertedStatus>Closed - Converted</tns:convertedStatus>
</tns:leadConverts>
</tns:convertLead>
</soap:Body>
</soap:Envelope>
curl -H 'SOAPAction: null' -H 'Content-Type: text/xml' --data BODY_FROM_ABOVE https://your-instance-url/services/Soap/u/52.0
Note that the SOAPAction header is required, even though Salesforce does not use it.
The result will be returned as XML similar to:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<LimitInfoHeader>
<limitInfo>
<current>91</current>
<limit>15000</limit>
<type>API REQUESTS</type>
</limitInfo>
</LimitInfoHeader>
</soapenv:Header>
<soapenv:Body>
<convertLeadResponse>
<result>
<accountId>0015x00002C95kMAAR</accountId>
<contactId>0035x00003NjdeyAAB</contactId>
<leadId>00Q5x00001tHg1tEAC</leadId>
<opportunityId>0065x000025fDsWAAU</opportunityId>
<success>true</success>
</result>
</convertLeadResponse>
</soapenv:Body>
</soapenv:Envelope>
If you are more comfortable with JSON than XML, OneGraph provides a GraphQL API that wraps the convertLead functionality.
It's best to create your own OneGraph app to get a custom app_id, but one is provided here for demonstration purposes.
The GraphQL query will be:
mutation ConvertLead {
salesforce(
auths: {
salesforceOAuth: {
instanceUrl: "YOUR_INSTANCE_URL"
token: "YOUR_OAUTH_TOKEN"
}
}
) {
convertLead(
input: { leadConverts: [{ leadId: "YOUR_LEAD_ID" }] }
) {
leadConverts {
lead {
id
name
}
account {
name
id
}
contact {
name
id
}
opportunity {
name
id
}
success
errors {
message
statusCode
}
}
}
}
}
Then the request will look like:
curl -H 'Content-Type: application/json' 'https://serve.onegraph.com/graphql?app_id=4687c59d-8f9c-494a-ab67-896fd706cee9' --data '{"query": "QUERY_FROM_ABOVE"}'
The result will be returned as JSON that looks like:
{
"data": {
"salesforce": {
"convertLead": {
"leadConverts": [
{
"lead": {
"id": "00Q5x00001tHg1tEAC",
"name": "Daniel Boone"
},
"account": {
"name": "Company",
"id": "0015x00002C95kMAAR"
},
"contact": {
"name": "Daniel Boone",
"id": "0035x00003NjdeyAAB"
},
"opportunity": {
"name": "New Opportunity",
"id": "0065x000025fDsWAAU"
},
"relatedPersonAccountId": null,
"success": true,
"errors": []
}
]
}
}
}
}