Serverless GET Requests

Hey, I’ve been reading up on the dev portal and the official doc for using a serverless app to make a get request. My requests always fail, does anyone have an updated version of a serverless app (for >9.0 SDK) call without an HTML file? When I make the call I see this in the logs.

2023-06-02 12:54:58.817 -0400 [debug] (e[34mdata-pipe.jse[0m) e[31mreceived call for route “request” with action “execute” and body {“data”:{“name”:“Docusigngetdoc”},“action”:“execute”}

Then it executes the request:
2023-06-02 12:54:58.819 -0400 [debug] (e[34mrequest.jse[0m) e[31mMaking request with options as {“method”:“GET”,“url”:"DocuSign ",“Content-Type”:“application/json”},“qs”:{},“body”:null,“maxAttempts”:1,“retryDelay”:0,“timeout”:5000}e[0m

And then I think this is it looking for an HTML page to send the data to:

2023-06-02 12:54:59.691 -0400 [debug] (e[34mrequest.jse[0m) e[31mLooking for “text/html” in application/json,application/xml,text/html,text/xml,application/jsonp,text/plain,application/javascript,application/vnd.api+json

Here’s what I have in my server.js file:

onAppInstallHandler: async function(args) {
console.log(‘Ticket create’ + args[‘account_id’]);
console.log('Testing uninstalling of App '+ args[‘email’]);
try {
let resp = await $request.invokeTemplate(“Docusigngetdoc”, {});
console.log(JSON.stringify(resp));
} catch (e) {
console.log(e);
}
renderData();
}

TLDR: I want to use a get request to get info to use, I don’t want to display anything and only want this to operate entirely as a backend-only type of application. If you have a method in mind that I can test, please let me know.

Hi @neverseenit ,

Here is a request template example you can refer to. Kindly update the same for your use case and try again.

    "fetchCustomerOrders": {
        "schema": {
            "protocol": "https",
            "method": "GET",
            "host": "<%=iparam.shopify_subdomain %>.myshopify.com",
            "path": "/admin/api/2023-04/orders.json",
            "query": {
                "email": "<%= context.customer_email %>"
            },
            "headers": {
                "Content-Type": "application/json",
                "X-Shopify-Access-Token": "<%=iparam.shopify_access_token %>"
            }
        },
        "options": {
            "maxAttempts": 0,
            "retryDelay": 1000,
            "isOAuth": false
        }
    }

Regards,
Thakur

1 Like

Thanks I’ll reach out soon