Unable to create listview using metadata api on Salesforce - soap

I am new to Salesforce metadata api. I want to create a listview of contacts on Salesforce using metadata api.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
<soap:Header>
<met:AllOrNoneHeader>
<met:allOrNone>false</met:allOrNone>
</met:AllOrNoneHeader>
<met:CallOptions>
<met:client>https://xyz.salesforce.com</met:client>
</met:CallOptions>
<met:SessionHeader>
<met:sessionId>xyz</met:sessionId>
</met:SessionHeader>
</soap:Header>
<soap:Body>
<met:createMetadata>
<!--Zero or more repetitions:-->
<met:metadata>
<!--Optional:-->
<met:fullName>TESTVIEW__c</met:fullName>
</met:metadata>
</met:createMetadata>
</soap:Body>
</soap:Envelope>
I am getting
[
{
"errorCode": "METHOD_NOT_ALLOWED",
"message": "HTTP Method 'POST' not allowed. Allowed are HEAD,GET"
}
]
The endpoint I use is:
https://xyz.salesforce.com/services/data/v51.0/sobjects/Contact/listviews
I updated to SOAP endpoint:
https://xyz-dev-ed.my.salesforce.com/services/Soap/m/51.0/1112312DRED21
Now I am getting
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>content-type of the request should be text/xml</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I guess I am one step closer. Is the payload valid for creation of contact listview?

You can't do a Metadata API deployment by making a POST to the REST API endpoint.
If you want to use a REST endpoint, use the REST deployRequest endpoint. If you want to use the SOAP createMetadata() call to which your payload appears to be oriented, you need to use the SOAP API.

Related

Do we have any SOAP API or REST API which will give us response/metadata with custom form and its fields

I am trying to get the metadata/fields of the custom forms in Netsuite. But the documentation of netsuite does not provide any direct way of doing this. Some pages mentioned using the SOAP Api's, So i tried using the SOAP api. Here is my api request in SOAP.
<?xml version="1.0"?>
<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soapenv:Header>
<ns1:searchPreferences
xmlns:ns1="urn:messages_2022_1.platform.webservices.netsuite.com" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
<ns1:pageSize>30</ns1:pageSize>
</ns1:searchPreferences>
<ns2:tokenPassport soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0"
xmlns:ns2="urn:messages_2022_1.platform.webservices.netsuite.com">
<ns3:account
xmlns:ns3="urn:core_2022_1.platform.webservices.netsuite.com">{{ACCOUNT}}
</ns3:account>
<ns4:consumerKey
xmlns:ns4="urn:core_2022_1.platform.webservices.netsuite.com">{{CONSUMER_KEY}}
</ns4:consumerKey>
<ns5:token
xmlns:ns5="urn:core_2022_1.platform.webservices.netsuite.com">{{TOKEN_ID}}
</ns5:token>
<ns6:nonce
xmlns:ns6="urn:core_2022_1.platform.webservices.netsuite.com">{{nonce}}
</ns6:nonce>
<ns7:timestamp
xmlns:ns7="urn:core_2022_1.platform.webservices.netsuite.com">{{timestamp}}
</ns7:timestamp>
<ns8:signature
xmlns:ns8="urn:core_2022_1.platform.webservices.netsuite.com" algorithm="HMAC-SHA256">{{signature}}
</ns8:signature>
</ns2:tokenPassport>
</soapenv:Header>
<soapenv:Body>
<getSelectValue>
<fieldDescription
xmlns:platformCore="urn:core_2022_1.platform.webservices.netsuite.com">
<platformCore:recordType>salesOrder</platformCore:recordType>
<platformCore:sublist
xmlns="urn:core_2022_1.platform.webservices.netsuite.com">customForm
</platformCore:sublist>
<platformCore:field>salesOrder</platformCore:field>
<platformCore:filterByValueList>
<platformCore:filterBy>
<platformCore:field>entity</platformCore:field>
<platformCore:internalId>164</platformCore:internalId>
</platformCore:filterBy>
</platformCore:filterByValueList>
</fieldDescription>
<pageIndex>1</pageIndex>
</getSelectValue>
</soapenv:Body>
</soapenv:Envelope>
The authorization and the signature generation are working correctly and it return actual response from netsuite. The response contains the list of all custom forms, but not the metadata/fields of the form i put in the filter part.
If there is any other way to do this let me know.

Manipulate soap request xml inside OnWriteStartBody(XmlDictionaryWriter writer)

I'm calling a soap web service that is very strict on the request from inside an asp.net core API.
by overriding OnWriteStartBody,OnWriteBodyContents,OnWriteStartEnvelope methods in the System.ServiceModel.Channels.Message class.
my XML
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://POWebservice/">
<soapenv:Body>
<ns1:myaction
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<trantype>purchase</trantype>
<tranamount>94999.23</tranamount>
</ns1:myaction>
</soapenv:Body>
</soapenv:Envelope>
what they expect :
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://POWebservice/">
<soapenv:Body>
<ns1:myaction>
<trantype>purchase</trantype>
<tranamount>94999.23</tranamount>
</ns1:myaction>
</soapenv:Body>
</soapenv:Envelope>
i want to get rid of xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
I have been able to modify some of the payload using
protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer)
{
writer.WriteStartElement("soapenv", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
}
i have also attempted to implement the IClientMessageInspector but the intercepted message in BeforeSendRequest had only the header and not the body. plus it had too many hacks .

Receiving No WS-Security Header error when attempting to POST to Cybersource Simple Order API

I am attempting to POST using Postman to the Cybersource Simple Order API, but it comes back with a no header error when doing so. What am I doing wrong here? Since the merchant ID is used as the username, what is used as the password, should this be the Simple Order transaction processing key?
Posting the following XML data to the test endpoint (https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor):
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>merchantname</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile1.0#PasswordText">key</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.150">
<merchantID>merchantname</merchantID>
<merchantReferenceCode>12345678912</merchantReferenceCode>
<recurringSubscriptionInfo>
<subscriptionID>12345678901234567890</subscriptionID>
</recurringSubscriptionInfo>
<paySubscriptionDeleteService run="true"/>
</requestMessage>
</soapenv:Body>
</soapenv:Envelope>
You have a small error in your namespaces. You missed a "-".
oasis-200401-wss-wssecurity-secext1.0.xsd
should be
oasis-200401-wss-wssecurity-secext-1.0.xsd
and
oasis-200401-wss-username-token-profile1.0#PasswordText
should be
oasis-200401-wss-username-token-profile-1.0#PasswordText

What are Servicenow SOAP API getkeys wildcards?

I'd like to use a SOAP request to get a list of items in servicenow table, that have description starting with "TEST".
I am able to send a simple getKeys request. For example the below one is successfully returning to me the sys_id of a single ticket:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hr="http://www.service-now.com/hr_case">
<soapenv:Header/>
<soapenv:Body>
<hr:getKeys>
<short_description>TEST Soap 1</short_description>
</hr:getKeys>
</soapenv:Body>
</soapenv:Envelope>
How should I modify the above request, so that it returns keys of all items with description starting with "TEST"?
I've used instead a REST webservice with the URI:
https://???.service-now.com/api/now/table/hr_case?sysparm_query=short_descriptionSTARTSWITHTEST
before then I tried a URI like that:
https://???.service-now.com/api/now/table/hr_case?&short_description=TEST Soap 1

Adwords SOAP XML request against ManagedCustomerService fails

I'm working with https://adwords.google.com/api/adwords/mcm/v201402/ManagedCustomerService and wanting to get the account hierarchy.
The requests are being made in raw XML (controlled by JScript) -- a bit perverse, I know, but that's the situation.
I've generated the following SOAP packet
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:RequestHeader soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="https://adwords.google.com/api/adwords/mcm/v201402">
<ns1:clientCustomerId>some_ccid</ns1:clientCustomerId>
<ns1:developerToken>some_developer_token</ns1:developerToken>
<ns1:userAgent>GAS</ns1:userAgent>
<ns1:validateOnly>false</ns1:validateOnly>
<ns1:partialFailure>false</ns1:partialFailure>
</ns1:RequestHeader>
</soapenv:Header>
<soapenv:Body>
<get xmlns="https://adwords.google.com/api/adwords/mcm/v201402">
<serviceSelector>
<fields>Login</fields>
<fields>Customer</fields>
<fields>Name</fields>
<predicate>
<field>id</field>
<operator>GREATER_THAN</operator>
<values>0</values>
</predicate>
</serviceSelector>
</get>
</soapenv:Body>
</soapenv:Envelope>
Please note the idGREATER_THAN0. This is my naive way of getting everything.
I notice that the PHP GetAccountHierarchy.php has
// Create selector.
$selector = new Selector();
// Specify the fields to retrieve.
$selector->fields = array('Login', 'CustomerId', 'Name');
// Make the get request.
$graph = $managedCustomerService->get($selector);
This would seem to imply that no predicate has been defined. However, I'm a bit leery of doing that because the documentation says (yes, I do read the friendly manual), "predicates ContentsNotNull"
The response I get is
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ns2:ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/mcm/v201402" xmlns="https://adwords.google.com/api/adwords/cm/v201402">
<requestId>0004f553e08eaca00abc25900000893f</requestId>
<serviceName>ManagedCustomerService</serviceName>
<methodName>get</methodName>
<operations>0</operations>
<responseTime>141</responseTime>
</ns2:ResponseHeader>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>[QuotaCheckError.INVALID_TOKEN_HEADER # ]</faultstring>
<detail>
<ns2:ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201402" xmlns:ns2="https://adwords.google.com/api/adwords/mcm/v201402">
<message>[QuotaCheckError.INVALID_TOKEN_HEADER # ]</message>
<ApplicationException.Type>ApiException</ApplicationException.Type>
<errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="QuotaCheckError">
<fieldPath/>
<trigger/>
<errorString>QuotaCheckError.INVALID_TOKEN_HEADER</errorString>
<ApiError.Type>QuotaCheckError</ApiError.Type>
<reason>INVALID_TOKEN_HEADER</reason>
</errors>
</ns2:ApiExceptionFault>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
What am I doing incorrectly that I should get such a response?
BTW, if I do leave out the predicate or specify it with a null content, I still get the QuotaCheckError.INVALID_TOKEN_HEADER error.
A solution has been provided on the Adwords API google group. Working nicely now!