Create Distribution through API: Subject from Library? | XM Community
Solved

Create Distribution through API: Subject from Library?

  • 13 April 2021
  • 1 reply
  • 32 views

Userlevel 7
Badge +26
  • QPN Level 4 ●●●●
  • 216 replies

Hi all,
I'm creating Distributions through the API https://{{host}}/API/v3/distributions
In the "message" part, I can indicate the libraryId + messageId of the email that I want to send. This email is translated into multiple languages, so the correct respondent receives the correct email in his language.
However, I can't find how to use a library message for the email subject.

I tried looking at a GET call for a distribution that does have an email subject from the library, like
https://{{host}}/API/v3/distributions/EMD_tnd2OfwerC0uRhp?surveyId=SV_a5g21DZrTZrYtRH
For emails with a fixed subject, it returns:
        "headers": {
            "fromEmail": "xxx",
            "replyToEmail": "xxx",
            "fromName": "xxx",
            "subject": "we want to know your opinion"
        }

While for emails with a library subject, it becomes
 "headers": {
      "fromEmail": "xxx",
      "replyToEmail": "xxx",
      "fromName": "xxx",
      "subjectMessage": {
        "messageId": "MS_6ulDgLSHi2yowpT",
        "libraryId": "GR_dhuve6yo89sajOt"
      }

But when I try to use this "subjectMessage" structure in a POST call for the distributions, I get the error
"errorMessage": "Expected param not found: subject",
I can't really seem to find something on the API guide about it... so I'm fearing it's not possible to use a library email subject?
Could anyone confirm this, or does someone know a way to do that? As I'm translating my emails, the subject should of course also be translated...

icon

Best answer by JoycaV 27 April 2021, 09:05

View original

1 reply

Userlevel 7
Badge +26

I contacted Qualtrics support about this, so if anyone ever encounters the same issue; this is the solution.
Instead of adding a structure like
"header": {
"fromEmail": "qtest@qemailserver.com",
"replyToEmail": "qtest@qemailserver.com",
"fromName": "Test Name",   
"subjectMessage": {
        "messageId": "MS_6ulDgLSHi2yowpT",
        "libraryId": "GR_dhuve6yo89sajOt"
      }
},
like it shows in a GET call,
for the POST you can just add the messageId directly in the subject attribute, so like this:
"header": {
"fromEmail": "qtest@qemailserver.com",
"replyToEmail": "qtest@qemailserver.com",
"fromName": "Test Name",
"subject": "MS_6ulDgLSHi2yowpT"
},

Leave a Reply