Can't access $db in a new serverless app

Hi,

I’m working on my first app for in-house use, and can’t seem to connect my local environment to our freshdesk-setup.
The current issue is just as simple as getting information via $db on a serverless app.

When logged in, I can check the existing records via the api. I just removed all code to have only the following statement remaining:

 $db.get("contact:************").then(
        console.log('checking...'),
        (data) => {
            console.log(data)
        }
    )

When checking the terminal for output, I get:
{ status: 404, message: 'Record not found' }

The only thing I’ve found is that possible my browser-plugin is outdated, but I couldn’t find another place to download a newer version. I’m currently on version 3.0.0

Please help this absolute noob :slight_smile:

Kind regards,

Jeroen

Hi,
Did you try to set the property before you retrieve it? The output means that record is not found. May I know which browser plugin you are referring to?


Can you please download the sdk from the above documentation?

Hi Mani,

Thank you for your quick reaction. It seems I’ve installed this plugin from some older source, and it’s not being used.
I’m using the newest version of fdk (6.9.7). I’m trying to connect it to our live-freshdesk, and clearly was expecting some magic for that to happen via that browser-plugin.

I’ve spend a couple of hours trying to connect my serverless local app via the API, but I couldn’t get that working either.
The error keeps calling me out on false credentials, but it feels like I’m doing exactly what this page tells me to:

      let headers = {"Authorization": "Basic <%= iparam.api_key %>"}
      let url = 'https://XXXXXXX.freshdesk.com/api/v2/contacts/' + id
      let options = {headers: headers };
      console.log(url + '\n' + custom)
      $request.get(url, options)
          .then(
              function (data) {
                console.log(data)
              },
              function (error) {
                console.log(error)
              }
          )
    }

What I’m really looking for is a way to test the API, and to create a serverless-app and be able to test with it.

The end result will be very simple; it needs to connect to an external API, get the response, and insert in the custom_fields for the contact from ticket_requester_id. Any help is greatly appreciated :slight_smile:

And ofcourse,
the same thing I did a million times today works now:

let headers = {"Authorization": "Basic <%= encode(iparam.api_key) %>"

My serverless app now connects to our freshdesk, and I can move on.
Party!

1 Like