Issue with delete-participants API call in extension | XM Community
Skip to main content

For some reason I cannot get a “delete-participants” API call to work in my extension.

I can make other calls work, so it is not the connection or authentication. I keep on getting a 500 (internal server error), unless if I deliberately configure the body as a string instead of an array, then I get a 400 error.

I have tried all possible and impossible options to format the body, but a no point have I been successful in getting this to work from the extension. It is not a problem to get this to work from Postman, but running it from the extension just does not work.

This is the simplified code (with project ID hidden):

module.exports = async function(context) {
    let getDeleteParticipants;
    
    try {
        const requestOptionsDelete = {
            method: "POST",
            body: S"DisableTestID"],      
        };

        getDeleteParticipants = await context.client.qualtricsApiFetch('ex-projects/TS_……./delete-participants', requestOptionsDelete);

        if (error.status === 201){
            return {
                message: 'Job completed without any errors.',
                getDeleteParticipants: getDeleteParticipants,
                errorStatus: error.status
            };
        } else {
            return {
                message: 'Job failed.',
                getDeleteParticipants: getDeleteParticipants,
                errorStatus: error.status
            };
        }
        
    } catch (error){    

        return {
            message: 'Error happened.',
            getDeleteParticipants: getDeleteParticipants,
            errorStatus: error.status
        };
    }

};

 

And this is the output:

{  "actionId": "OCAC_ITu8fegq6eeSfFI",  "exports": {    "getDeleteParticipants": {      "responseData": {        "error": {          "errorCode": "DPG_0.0",          "errorMessage": "An unexpected error occurred."        },        "meta": {          "httpStatusCode": 500,          "requestId": "1798ee66-73eb-48db-8e9e-899b24702d6e"        }      },      "status": 500    },    "message": "Error happened."  }}

Can anyone make this work?

Hi @JesperAndersen 

I’m going to have our teams look at this, but in the meantime, using context.client.fetch does actually work for this API. The downside is that you have to take in a client credential to do it, so using the generic fetch may not work. Let me know.

deleteParticipantBody =  'email@domain.com'];

const fetchPostResponse = await context.client.fetch(`https://yul1.qualtrics.com/API/v3/ex-projects/${projectId}/delete-participants`, {
method: 'POST',
body: deleteParticipantBody,
connection: {
connectionName: 'connName',
paramFormat: 'header',
paramName: 'X-API-TOKEN',
paramTemplate: '%s'
}
});

 


Hi @JesperAndersen 

The qualtricsApiFetch method should now work for delete-participant in ex-projects now. 

Give it a shot and let me know if you run into anything else. 


Hi @qHubert,

Sorry for the slow response, but I have been on vacation, so not near my work laptop.

Thanks, I can confirm this is now working! 😀😀

Not sure what you did to make it work, but it is much appreciated!!

Thanks again!


Leave a Reply