//native
type Pinterest = {
token: string;
};
/**
* Create lead form test data
* Create lead form test data based on the list of answers provided as part of the body.
- List of answers should follow the questions creation order.
This endpoint is currently in beta and not available to all apps. Learn more.
*/
export async function main(
auth: Pinterest,
ad_account_id: string,
lead_form_id: string,
body: { answers: string[] },
) {
const url = new URL(
`https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/lead_forms/${lead_form_id}/test`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 536 days ago