Jerome.Saint-Marc Genesys Employee
February 23

I assume you did not run a file with just this code extract in it. I cannot guess/try if you don't share more. I would need to see what's the rest of your code.

Also what version of nodejs are you using?
What are you using to run this test (I mean running this on your computer? is that lambda logs?)?

I would start with checking if you have not declared the hpagent import somewhere else in your code.
Also, if you declare a file with mjs extension, it means that you want to import using ECMAScript module approach (using "import").
Using import of modules using "require" is for CommonJS modules.

Regards,


Visit Topic to respond.


Previous Replies

yonezawa
February 22

Thanks for the info, but I wrote below, but it gave me an error.
‐‐‐‐‐‐‐‐‐‐
const{HttpsProxyAgent}= require('hpagent');
const client = platformClient.ApiClient.instance;
agent = new HttpsProxyAgent({
proxy: proxyUrl,
});
client.setProxyAgent(agent);
‐‐‐‐‐‐‐‐‐‐

I would like to know how to solve this problem.

‐‐‐‐‐‐‐‐‐
2025-02-22T15:45:44.795Z undefined ERROR Uncaught Exception {
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Identifier 'HttpsProxyAgent' has already been declared",
"stack": [
"Runtime.UserCodeSyntaxError: SyntaxError: Identifier 'HttpsProxyAgent' has already been declared",
" at _loadUserApp (file:///var/runtime/index.mjs:1084:17)",
" at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)",
" at async start (file:///var/runtime/index.mjs:1282:23)",
" at async file:///var/runtime/index.mjs:1288:1"
]
}
‐‐‐‐‐‐‐‐‐

Jerome.Saint-Marc Genesys Employee
February 21

Hello,

const {HttpsProxyAgent} = require('hpagent')
const client = platformClient.ApiClient.instance;

agent = new HttpsProxyAgent({
  proxy: proxyUrl,
});
client.setProxyAgent(agent)

new HttpsProxyAgent and not new HttpProxyAgent

Regards,

yonezawa
February 21

I am trying to create a function on AWS lambda to
retrieve GenesysCloud information.

However, I need to go through a proxy, and I am referring to the Using a Proxy (Node.js only) section of the following page as follows.

SDK Doc Viewer

Genesys Cloud Platform Client SDK Documentation Viewer

‐‐‐‐‐‐‐‐
const proxyUrl = process.env.HTTP_PROXY;
const client = platformClient.ApiClient.instance;
const agent = new HttpProxyAgent({
proxy: proxyUrl,
});
client.setProxyAgent(agent);
‐‐‐‐‐‐‐‐

I get the following error and do not know how to resolve it.

・TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"


Visit Topic to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, click here.