Unable to create JIRA issue from Confluence
Asked by P S:

Hello,

I've spent a lot of time trying to get this to work, but no luck.

My goal is from Confluence to create JIRA issues using the JIRA API.

I've tried the 2 approaches below, each of them returning their own errors. At this stage I'm not sure if its due the request I'm making or our JIRA setup (and fyi I have no access to the JIRA/Confluence admin settings, I'm just a user).

In both approaches I have a Confluence page with a HTML section in which I have the following code.

#### Approach 1 {#toc-hId-144582003}

```
let reqData = {
   "project": {
      "id": "1001"
   }
   // some more fields here, just simplifying 
}
```

```
function createMCC() {

  jQuery.ajax({

    type: "POST",
    url: 'https://<MY_CONFLUENCE_URL>/plugins/servlet/applinks/proxy?appId=<JIRA APPID>&path=https://<MY JIRA URL>/rest/api/latest/issue',
    data: JSON.stringify(reqData),
    contentType: "application/json; charset=utf-8",
    processData: false,
    headers: { 'X-Atlassian-Token': 'no-check', 'Accept': 'application/json', 'Content-Type': 'application/json' },
    dataType: "json",
    async: false,
    success: function (data) {
      console.log(data)
    },
    error: function (data) {
       console.log(data)
    }
 });

 }
```

This returns a 400 response with the error:  

```
The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
```

#### Approach 2 {#toc-hId--1662872460}

```
let reqData = {
 issues: [{
   "project": {
      "id": "1001"
   }
   // some more fields here, just simplifying
 }]
}
```

```
function createMCC() {

  jQuery.ajax({

    type: "POST",
    url: 'https://<MY CONFLUENCE URL>/rest/jira-integration/latest/issues?applicationId=<JIRA APP ID>',
    data: JSON.stringify(reqData),
    contentType: "application/json; charset=utf-8",
    processData: false,
    headers: { 'X-Atlassian-Token': 'no-check', 'Accept': 'application/json', 'Content-Type': 'application/json' },
    dataType: "json",
    async: false,
    success: function (data) {
      console.log(data)
    },
    error: function (data) {
       console.log(data)
    }
 });

 }
```

Returns a 500 response with the error:

1.

   ```
   exceptionName: "com.atlassian.integration.jira.JiraCommunicationException"
   ```

2.

   ```
   message: "The server may be unreachable. Please ensure you are running Jira 5.0 or higher."
   ```

Any help appreciated.

Thanks.


Answers:
author: Srinatha T
body: Hi [@P S](/t5/user/viewprofilepage/user-id/4904560) ,

Welcome to Atlassian community.

You are using the cloud version or server ? I have very basic knowledge on API's , so other community members might help with above errors.

For server we had this [article](https://developer.atlassian.com/server/jira/platform/performing-issue-operations/) which has some example code for you. We have some other ways of creating issue's from confluence and you might want to refer the below URL

* [Use-jira-applications-and-confluence-together](https://confluence.atlassian.com/doc/use-jira-applications-and-confluence-together-427623543.html)

Have a good day!

Thanks,

Srinath T


Tags: cloud

confluence-cloud

jira