Unable to send post requests to server

I am trying to test an app that integrates FD with Youtrack.
I have a server that has Youtruck running on it, in which I would like to test calls to and from this server from my local Freshdesk app.
However, I am struggling to find out how to make these post requests.
One of my functions from my app.js is as follows:

var youtrackURL = "XX.XXX.X.XXX:XXXX"

function createET() {
  var url = "https://${youtrackURL}/api/issues?fields=idReadable";
  console.log(url);
  var body = {
    "project": {"id": "0-0"},
    "summary": document.getElementById("summaryId").value,
    "description": document.getElementById("descriptionId").value,
    "customFields": [
      {
        "name": "Priority",
        "$type": "SingleEnumIssueCustomField",
        "value": document.getElementById("priorityId").value
      },
      {
        "name": "Assignee",
        "$type": "SingleUserIssueCustomField",
        "value": document.getElementById("assigneeId").value
      },
      {
        "name": "Subsystem",
        "$type": "SingleUserIssueCustomField",
        "value": "No Subsystem"
      }
    ]
  }
  const options = {
    headers: {
      Authorization: `Basic <%= encode(iparam.YT_apiKey) %>`,
      "Content-Type": "application/json"
    },
    body,
    isOAuth: true,
    method: "POST"
  };
  console.log(options);
  client.request.post(url, options, body)
  .then(
    function(data) {
      console.log(data);
    },
    function(error) {
      console.log(error);
    }
  )
}

In the below topic, I can see that requests to IP addresses are not allowed, is this for all FD custom apps?
If so, how can I work around this? Can I simply add this IP to a hosts file in my app directory?

Below is my fdk.log file
fdk.log (1019.9 KB)

Also, for further details on my application make-up, I have raised a previous topic here: Failed to fetch installation parameters - #20 by Raviraj

Any help would be greatly appreciated, thanks! :slight_smile:

Hi @Ayoub_Sebtane,

If you would like to test another application API by running it locally, you can make the application run within your system to work in the localhost URL. The localhost URL is supported and the HTTP URL will work with it.

For any other IP address, it’s not allowed to make API requests with them via the Request Method platform feature. You would have to look out for alternative ways to do this.

Some of them I could suggest are,

  1. You can assign a domain for the IP address where the application runs to test them.
  2. You can use a tool like ngrok to run a proxy that will provide a domain mapping for the IP address of the application.
  3. You can use a 3rd party HTTP library to make the API request from the app from the Serverless component. It will not have this restriction. But, the Request method’s feature of Static IP will not be available with it.
2 Likes