I'm trying to await post request. I've found request-promise-native
package to make await requests. It works for GET requests but doesn't work with the POST. The URL is working, the auth hash is working as well as I've tested it with `curl.
import * as request from "request-promise-native";
async sendRequest(uri: string, method: string): Promise<any> {
var options = {
uri: uri,
headers: {
"Authorization": 'Basic ' + 'someValidHashValue'
},
method: method,
json: true
};
try {
const result = await request.get(options);
return result;
}
catch (err) {
console.log(err);
}
}
async queueBambooPlan(fileName: string) {
let bambooHost: string | undefined = vscode.workspace.getConfiguration('markdown-table-of-contents').get('atlassianBambooHost');
let planKey = await this.getBambooPlanKey(fileName, bambooHost);
let uri = `${bambooHost}/rest/api/latest/queue/${planKey}`;
let response = await this.sendRequest(uri, 'post');
}
405 - "Apache Tomcat/8.0.36 - Error reportH1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}
HTTP Status 405 - Method Not Allowed
type Status report
message Method Not Allowed
description The specified HTTP method is not allowed for the requested resource.
Apache Tomcat/8.0.36
The request from above worked using fiddler
, however it is not working from the code.
UPDATE: I've wrote the code using standard request package and it is working:
await
inside of an async function... just throwing that out there. So the lineawait this.sendRequest()
is invalid. - Isaac Vidrine