Hi,
Im trying to connect an MCC account to a Google Ads account following the 
following 
link 
https://developers.google.com/google-ads/api/rest/reference/rest/v16/customers.accountLinks/create

export async function createAccountLink(
managerCustomerId,
clientCustomerId,
clientAccessToken
) {
const url = `https://googleads.googleapis.com/v16/customers/${
managerCustomerId}/accountLinks:create`;

// The payload for the POST request
const body = {
accountLink: {
status: "PENDING_APPROVAL",
},
};

try {
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${clientAccessToken}`, // Bearer token for the 
client account
"Developer-Token": process.env.GOOGLE_DEV_TOKEN, // Developer token for API 
access
"Content-Type": "application/json",
"login-customer-id": managerCustomerId, // Manager account ID
},
body: JSON.stringify(body), // Converting the payload to a JSON string
});

if (!response.ok) {
const responseText = await response.text();
console.error(
`Failed to create account link, status: ${response.status}, response: ${
responseText}`
);
throw new Error(
`API call failed with status ${response.status}: ${responseText}`
);
}

const data = await response.json();
console.log("Created Account Link:", data);
return data;
} catch (error) {
console.error("Failed to create account link:", error);
throw error;
}
}

I believe I'm missing fields in the body request but I do not understand 
which ones are required. Do I need to add "type"? What would be the value? 
"Unknown"? I also couldn't find where to add the CID for the account I'm 
trying to connect. 

Looking for some guidance here. Appreciate the help!
Thanks!

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/c78d7622-c531-47c9-b3a1-a0121c3516a9n%40googlegroups.com.

Reply via email to