Hey everyone,
I’m currently running into a problem with the application I’m writing. I’m working in Angular 5 for the first time and I’ve been trying to update the assignee of an issue.
When I test my method in Postman it passes and the information gets changed, but when I try it with my application in my browser (Google Chrome) I get the following error:
‘Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.’
This error occurs when it’s in the OPTIONS request.
Differences in results (Google Chrome and Postman)
The status code I get back in my browser is 200. In Postman this is 204.
In my browser it does not seem to get to the PUT request.
The ‘X-AUSERNAME’ in my browser is ‘anonymous’, but in Postman this is my own username. I also can’t find an Authorization header in my request headers in my browser. I do however set the header before I make the request. This doesn’t occur when I’m executing a GET request. The other headers I set seem to be missing in the request headers as well.
This picture is the code I’m using at this time
updateReporterByIssueKey(key, assignee, description) {
const prefix = `https://my-domain-here/rest/api/2/issue/${key}`;
const jsonString = `{
"update": {
"description": [
{
"set": "${description};"
}
]
},
"fields": {
"assignee":{"name":"${assignee}"}
}
}`;
const httpOptions = {
headers: new HttpHeaders({
Authorization: 'Basic ' + btoa(this.authorization),
Accept: 'application/json',
'Content-Type': 'application/json'
})
};
const request = {
httpRequest: new HttpRequest("PUT",prefix,JSON.stringify(jsonString),{headers: httpOptions.headers, responseType: 'json'})
};
This is the request header from my browser
Anyone who ran into a similar problem?