Error 403 when trying to do Jira REST API POST request

Hello everyone, I have some problem with the Jira API and the POST request on the website.
Here I am trying to do a POST request from my WordPress website with Basic Authorization

<button type="submit" onclick="postApi()">POST</button>

    function postApi(){
            mode: 'no-cors',
            method: 'POST',
            headers: {
                'Authorization': 'Basic ' + btoa('MY_USERNAME' + ':' + 'MY_TOKEN'),
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            "data": JSON.stringify({
              "fields": {
                "project": {
                "summary": "Test applicant",
                "description": "Hi and Hi", 
                "customfield_10034": "fname", 
                "customfield_10035": "lname", 
                "issuetype": {"name": "Task"}
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error))

The data put in there is just for me to test the API to work, no worries about that.
The problem is the console showing me that there is a 403 error which means that I have no permission to complete the action while it works on Postman :cry:

Does anyone know what the underlying problems are here? :thinking: Please let me know
Thanks so much and I’ll appreciate every reply :innocent:

Hey, looks like the error is in the way you’re building your Auth header:

'Basic' + btoa(...) should be Basic ${btoa(...)} or without template litterals 'Basic ' + btoa(...). Notice the space after basic.

1 Like

Thanks for the reply :hugs:. My mistake right there, I had the space in my code and made a mistake when pasting the code here