Hi,
I’m working on my master’s degree developing a privacy plugin that needs to send information to my framework by API. I’m developing a Forge Application and now I’m trying to send that information by POST, I added the permissions below and everything seems well but, nothing is happening. What I’m doing is it possible? Does someone have some tips?
This is my function:
function sendToOrchestrator(message){
api.fetch(`####.compute.amazonaws.com:5000/send`,
{
body:message,
method: "post",
headers: { 'Content-Type': 'application/json' },
}
)
console.log("Message:"+message)
};
This is manifest.yml:
permissions:
scopes:
- read:jira-work
- storage:app
external:
fetch:
backend:
- '*.amazonaws.com'
client:
- '*.amazonaws.com'
Hi @paulohsilva! Try to await
the promise returned by api.fetch
. Otherwise, the function returns before the request is sent:
async function sendToOrchestrator(message) {
await api.fetch(...);
...
}
2 Likes
Hi, @klaussner. Thanks, now a warnig has appeared in the first request I do, probably because of your explanations, but I haven’t managed to send the “message” to my API. What is been shown to me in the terminal is:
(node:8) [DEP0118] DeprecationWarning: The provided hostname “” is not a valid hostname, and is supported in the dns module solely for compatibility.
(Use node --trace-deprecation ...
to show where the warning was created)
Also, during my tries, I added to URL the protocol “HTTP”, when I did it the bellow suggestion from lint appeared. The lint added the complete URL to manifest.yml.
After I deploy and upgrade the installation I try again but nothing is sent to my API. Do you have suggestions or tips?
/app/src/index.jsx
91:32 error The domain http://*****.us-east-2.compute.amazonaws.com:5000/send is not included in the external permissions of your app manifest egress-permission-required
X 1 issue (1 error, 0 warnings)
Run forge lint --fix to automatically fix 1 error and 0 warnings.
This is the current function where the external API is called
async function sendToOrchestrator(message){
const res = await api.fetch('*****.compute.amazonaws.com:5000/send',
{
body:JSON.stringify(message),
method: 'post',
headers: { 'Content-Type': 'application/json' },
}
)
const data = await res.json();
console.log("Message:"+data)
};
This is the current manifest.yml
modules:
jira:issuePanel:
- key: framework-plugin-hello-world-panel
function: main
title: Forge App for Master Degree
icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
function:
- key: main
handler: index.run
app:
id: ari:cloud:ecosystem::app/e4e5dc8e-fc27-4e99-804b-4b6167ce073a
permissions:
scopes:
- read:jira-work
- storage:app
external:
fetch:
backend:
- ITWASADDEDAFTERLINT.us-east-2.compute.amazonaws.com
- "*.us-east-2.compute.amazonaws.com"
- "*.amazonaws.com"
client:
- "*.amazonaws.com"
- "*.us-east-2.compute.amazonaws.com"
I’m not sure but maybe the port must be included in the external permission.
Hi, @klaussner, thank’s for your help!
After some hours I found the problem.
The target endpoint needs to be secure.
- I bought a domain, (I’ll need this)
- I generated a certificate for it,
- I added it to the manifest.yml
Now it’s working, but for knowledge:
- I also generated a subdomain and I had the same problem because the certificate didn’t consider secure, and the “api.fetch” just waits for HTTPS protocol in front of the URL(not validate it) and does not show any error.
My learnings here: In my examples here I didn’t show de protocol
1 Like