Skip to main content

How would I use a different endpoint for each integration user? I have a slightly different endpoint for each client and would like them to enter the URL (or part of the URL) as part of zap setup.

 

Bruce

@brucewheaton Sounds like you made some progress! You just need to fix the url in the request, it should be bundle.authData.api_url instead of bundle.auth.api_url.


 

Add an authentication field, which will prompt the user as they are configuring their credentials for your app.  

 

You can define an input mask as well to help your users understand what part of the URL you’re expecting them to enter. 

 

 


@brucewheaton - In that case, you’ll need to switch to API Key authentication scheme and add the Basic authentication fields manually then in your triggers and actions, you should switch to the code mode.

If you name the Basic authentication fields username & password then the Authorization header should be assigned this value: "Basic " + Buffer.from(bundle.authData.username + ":" + bundle.authData.password).toString("base64")


Thanks again!

 

EDIT - damn. Somehow bundle.auth.api_url got inserted there, not bundle.authData.api_url.

 

Works great now!

 

That makes sense, and I edited the auth and test sections, got a good test, but when I try to test the API I get:

TypeError: Cannot read property 'api_url' of undefined at eval (eval at makeFunction (/var/task/node_modules/zapier-platform-core/src/tools/schema-tools.js:11:39), <anonymous>:4:20)

The code looks like this:

const options = {
  url: bundle.auth.api_url,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': "Basic " + Buffer.from(bundle.authData.username + ":" + bundle.authData.password).toString("base64"),
    'X-VEVOMO-ATTENDEE-TYPE': bundle.inputData.vevomo_attendee_type
  },

and I set a new ‘account’ to be sure that the URL was in there (same values that worked for the test).

 

Feels like it’s close but the auth isn’t there? The same code works in the test area.

 


@brucewheaton - Add a field for the API URL in the authentication, let’s call it api_url. You can reference it later from {{bundle.authData.api_url}}.


Thanks!

As an environment variable? 

ThenI can reference that environment variable in the URL field?


@brucewheaton You’re welcome!

As an environment variable, it will be the same for all the users. You’ll need to add it as an authentication field instead so that each connection has its own API URL.


That makes sense - I don’t see where to add that though, do I need to switch to ‘Code Mode’? There’s a ‘Connection Label’ item on that page but no variables to edit/add.


Ah, that could be why I don’t see it - I’m using Basic Auth for this (as a sort of API key).

Is there still a way to do it?