How to use a mail template ID when sending an email with admin api in shopware 6? - shopware6

When sending an email via Shopware 6 admin api (https://shopware.stoplight.io/docs/admin-api/b3A6MTI2MjUzOTg-send-a-mail) i would like to pass only the mail template ID, and not the other information from the template (contentHtml, contentPlain, subject).
Do you know if this is possible ?

This endpoint was not implemented to fetch an existing mail_template entity by an id. You'll have to provide the mails content yourself.
Your best bet would be to send a request to the corresponding endpoint for mail templates, e.g. GET /api/mail-template/086f8adc94f14a618e3729d933befb8d, and retrieve the values for subject, contentHtml and contentPlain from the response. These will still be un-rendered Twig at that point. So there should be no problem in passing them with your POST /api/_action/mail-template/send request. Just remember that you have to provide the data for the variables used in the templates. It looks like this isn't documented, but you need to provide the data in the request body with the key mailTemplateData.
So as an example see this abbreviated request body:
{
"contentPlain": "Hello {{ user.firstName }}!", // retrieved by `/api/mail-template/:id`
"mailTemplateData": {
"user": {
"firstName": "Pete"
}
}
}

Related

Karate API -> JSON Request -> Base field in JSON not being sent in request (works in Postman)

My JSON request has a base value that is the top object.
Sample:
{
"partner_id": "6f4a3092-1b11-48c0-8a11-ae455b327ed8",
"borrowers": [
{
"loan": {
"loan_number": "89898989898222",
The partner_id is not being sent with the rest of the request.
Does this first object require special treatment to be sent with the rest of the request?
It feels like it should 'just work'
In my steps to file a bug, it started working in picking up the base object.

Linking a Contact to a Customer using the SOAP API

I’m having an issue with linking a customer object to a pre-existing contact when creating a new customer within the SOAP/SuiteTalk API using the Mulesoft middleware.
I’m successfully creating the contact object earlier, and then trying to use that internal ID to link that contact object to the newly created customer object. The relevant part I’m posting within the customer object (just hardcoding the internal ID in order to get it running):
contactRolesList:
{
contactRoles:
[
{
contact: {
"type": "CONTACT",
internalId: '74335',
},
role: {
"type": "CONTACT_ROLE",
internalId: ‘-10’,
}
}
]
}
When I attempt to upsert the customer object this way, I don’t get any errors in the integration role execution log, but the contact is never linked. If I try to upsert a second time, I get an error with the format: Unable to find a matching line for sublist contactroles with key: [contact] and value: [74335]. even though a contact object with that internal ID clearly exists.
Am I going about this entirely the wrong way, or am I just narrowly missing the syntax here?
*As a side note, is it possible to set the relationship on a RecordRef using just the external ID? As in, using just the external ID of the contact object in question to reference it and create the link?
Thank you.
The "contactRolesList" field is only for updating contacts already connected to the customer. In order to link a contact with a customer you need to perform an attach operation.
I'm not experienced with the Mulesoft middleware you mention, but in a soap request it would look like this:
<attach xmlns="urn:messages_2017_1.platform.webservices.netsuite.com">
<attachReferece xsi:type="ns1:AttachContactReference"
xmlns:ns1="urn:core_2017_1.platform.webservices.netsuite.com">
<ns1:attachTo internalId="176" type="customer" xsi:type="ns1:RecordRef">
</ns1:attachTo>
<ns1:contact internalId="1467" xsi:type="ns1:RecordRef"/>
<ns1:contactRole internalId="-10" xsi:type="ns1:RecordRef">
</ns1:contactRole>
</attachReferece>
</attach>
You can get additional information in your netsuite CRM's help center at: SuiteCloud Platform/ SuiteTalk Web Services /SuiteTalk SOAP Web Services Platform Guide /SOAP Web Services Operations attach - detach

Wso2 scim/Users endpoint brings less attributes

Using the wso2/scim/Users endpoint as described in doc i am supposed to get a response like this one
{
"schemas":[
"urn:scim:schemas:core:1.0"
],
"totalResults":2,
"Resources":[
{
"id":"0032fd29-55a9-4fb9-be82-b1c97c073f02",
"userName":"hasinitg",
"meta":{
"lastModified":"2016-01-26T16:46:53",
"created":"2016-01-26T16:46:53",
"location":"https://localhost:9443/wso2/scim/Users/0032fd29-55a9-4fb9-be82-b1c97c073f02"
}
},
{
"id":"b228b59d-db19-4064-b637-d33c31209fae",
"userName":"pulasthim",
"meta":{
"lastModified":"2016-01-26T17:00:33",
"created":"2016-01-26T17:00:33",
"location":"https://localhost:9443/wso2/scim/Users/b228b59d-db19-4064-b637-d33c31209fae"
}
}
]
}
But i need some extra info for every user and doing subsequent requests for every user using the id to get the extra information (like an email) is too bad.
Is it possible to configure the endpoint response so that i get the information needed for the users in one request ?
You should be able to do this with SCIM extensions.
This blog post has more details.
In WSO2 Identity server 5.3.0, you can achieve this by using the attributes query parameter.
eg. Following request will list all users along with their given names in a single call.
curl -k --user admin:admin 'https://localhost:9443/wso2/scim/Users?attributes=givenname'
Please refer the post here for more details.

How to get AWS API Gateway to validate JSON Body against Model

The newly released "x-amazon-apigateway-request-validator" (in April I believe) is supposed to be able to run a JSON schema validation against the POST/PUT payload of an API.
I've tried to implement this in several different ways now but I can't make it work...
I have added the validators:
"x-amazon-apigateway-request-validators": {
"ValidateBody": {
"validateRequestParameters": false,
"validateRequestBody": true
},
"ValidateHeaders": {
"validateRequestParameters": true,
"validateRequestBody": false
}
}
For any methind I will look for specific headers so I also have the parameters in the "root" of the Swagger:
"x-amazon-apigateway-request-validator": "ValidateHeaders"
In the POST I have a x-amazon-apigateway-request-validator: ValidateBody and then a Model with the JSON schema where several elements are required.
I can however POST anything as long as it is JSON... There is no validation against the JSON schema done...
What am I missing?
It is working!
There is a time lag between the deploy and the actual usage of the new code even though I am not doing any caching it seems.
Went out for lunch and came back to a working solution!
{
"message": "Invalid request body"
}
It would be nice to be able to modify the response message though...

Unable to receive recipient view url of docusign

I am using docusign_rest gem. I am creating template with
create_template
method and envelope with
create_envelope_from_template
method.
But when I was trying to retrieving the url for embedded signing with the help of following code
client = DocusignRest::Client.new
#url = client.get_recipient_view(
envelope_id: #envelope_response["envelopeId"],
name: 'some_name',
email: 'some_email',
return_url: 'http://google.com'
)
then it returning nil. So I am unable to generate url.
When I am using the iodocs portal of docusign for the same POST request
Recipient v2/accounts/:accountId/envelopes/:envelopeId/views/recipient
{
"authenticationMethod": "email",
"email": "some_email",
"returnUrl": "www.gmail.com",
"userName": "some_name",
"clientUserId": "some_email"
}
I get the url as required.
So am I doing something incorrect in the ruby gem's call or is there a bug?
user2593706 : this will return nil because u r not passing any value #envelope_response["envelopeId"] so u need to pass the envelope id which is created previously or any other u want to get response. in rails its very easy to implement... if u want to look at response from docusign u need to use your terminal for that.. do this...
1. rails c
2. paste your create_template method code as yours
3. paste your create_envelope_from_template code
4. then run immediately your code
client = DocusignRest::Client.new
#url = client.get_recipient_view(
envelope_id: #envelope_response["envelopeId"],
name: 'some_name',
email: 'some_email',
return_url: 'http://google.com'
)
then u will get ur response.... hope this works. and its really good to do this task
To use embedding functionality for a given envelope, you need to set the clientUserId property at the time the envelope is being created, then you reference it again with the same value when requesting the URL (just like you have in your code).
This page from the DocuSign Dev Center explains it in more detail:
http://www.docusign.com/developer-center/explore/features/embedding-docusign