401 - Unauthorized Access

Hello,

I am integrating a contact form with the Pipedrive API. We are using a token to authenticate. I am trying to send a request to the itemSearch endpoint, but I am getting back a 401 - Unauthorized access. When I run the request on Postman with the same token it works just fine.
I’ve tried also to run the request on other endpoints but I am still getting back the same response.

This is a snippet of the code I am using at the moment:

const searchItem = (searchTerm) => {

    const itemSearchAPIUrl = `${baseUrl}/v1/itemSearch?term=${searchTerm}&search_for_related_items=1?api_token=${apiKey}`;

    const config = {

      method: "get",

      url: itemSearchAPIUrl,

    };

    axios(config)

      .then(function (response) {

        console.log(JSON.stringify(response.data));

      })

      .catch(function (error) {

        console.log(error);

      });

  };

Hey @Ilaria_Callegari
Welcome to the community :raised_hands:
Thanks for sharing your snippet :slight_smile:
From the looks of it, I see that there is an issue with the query string params

it should ideally be

Ampersand instead of a question mark before api_token param

Let me know if it helps