I am facing an issue where I am not able to update the DataExtract (File Convert) activity via Rest below API in SSJS script activity.
In the API response I am getting below error
API Responsse : {"errors":[{"message":"The following field is required: 'DataExtractTypeId'."}]}
Though I am passing the DataExtractTypeId in the request payload , still I am getting this error.
Note : The same request works fine via POSTMAN, but via cloud Page , it is giving above error
Details are as follows:
URI : https:{{hostname}}.rest.marketingcloudapis.com/automation/v1/dataextracts/{{dataExtractDefId}}
METHOD: PATCH
REQUEST:
{
"name": "Email_FileConvert",
"key": "Email_FileConvert",
"description": "",
"fileSpec": "emails_verified_test.csv",
"dataFields": [
{
"name": "ConvertTo",
"type": "dropdown",
"value": "UTF8"
},
{
"name": "Folder",
"type": "string",
"value": ""
},
{
"name": "IsFileInSafeHouse",
"type": "bool",
"value": "True"
}
],
"dataExtractDefinitionId": {{dataExtractDefId}},
"dataExtractTypeId": "35314e6a-929e-487e-81f8-70366d7679d3",
"createdBy": 12345,
"modifiedBy": 12345,
"intervalType": 0,
"extractTypeName": "File Convert"
}
**ssjs headers:**
var auth = "Bearer " + accessToken;
var req = new Script.Util.HttpRequest(requestUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json"
req.setHeader("Authorization",auth);
req.method = "PATCH";
req.postData =payload;
var resp = req.send();
varresponseBody=Platform.Function.ParseJSON(String(resp.content));
Write('API RESPONSE:'+Stringify(responseBody));
Also, the below request for Updating DataExtract-Data Extention activity type, it is getting updated successfully from the CLoud Page SSJS
URI
https://{{et_subdomain_test}}.rest.marketingcloudapis.com/automation/v1/dataextracts/{{extract_def_id}}
Request:
{
"name": "Emails_Export",
"key": "Emails_Export",
"description": "",
"fileSpec":"emails_verified_test.csv",
"dataFields": [
{
"name": "ColumnDelimiter",
"type": "string",
"value": ","
},
{
"name": "DECustomerKey",
"type": "string",
"value": "Verfied_Emails_Export_DE"
},
{
"name": "HasColumnHeaders",
"type": "bool",
"value": "True"
},
{
"name": "TextQualified",
"type": "bool",
"value": "True"
},
{
"name": "UsesLineFeed",
"type": "bool",
"value": "False"
}
],
"dataExtractDefinitionId":{{extract_def_id}},
"dataExtractTypeId": "bb94a04d-9632-4623-be47-daabc3f588a6",
"createdBy": 123456,
"modifiedBy": 123456,
"intervalType": 0,
"extractTypeName": "Data Extension Extract"
}
application/json
) ? Maybe postman sets that correctly for you without you knowing, and a cloudpage isn't so generous.