Discussions

Ask a Question
Back to All

I'm getting 401 "Error: Request failed with status code 401", when i hit this api for creating user.

const apiEndpoint = `https://api.adapty.io/api/v1/sdk/profiles/`;
const apiKey = 'secret_live_BEHrYLTr.************\*\*\*************';
const headers = {
  Authorization: `Api-Key ${apiKey}`,
  'Content-Type': 'application/json',
};
let data = {
      customer_user_id: "45456456465",
    };

    axios
      .post(apiEndpoint, data, { headers })
      .then((response) => {
        console.log("Response:", response.data);
      })
      .catch((error) => {
        console.log("error", error);
        console.error("Error:", error.message);
      });