Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

A doubt about CURL post command

Max October 30, 2018

Hi everyone.

I am able to use the CURL get command to GET an issue from JIRA server.

curl -D- -u test:test123 -X GET -H "Content-Type: application/json" http://x.x.x.x:7070/issue/rest/api/2/search?jql=key+in+('TEST001')+AND+project+in+('projectname')

This works fine. It returns the actual issue on the shell prompt the output.

But when it comes to a POST instruction,

I did the following :

curl -D- -u test:test123 -X POST --data @send.json -H "Content-Type: application/json" http://x.x.x.x:7070/issue/rest/api/2/issue

And inside my send.json, I had the following:

{"project":{"key":"projectname"},"summary":"Testing REST API","issuetype": {"name": "Task"}}

But I get the error even though my JSON text is properly formatted. The :

{"errorMessages":["Internal server error"],"errors":{}}

Any ideas why?

1 answer

1 accepted

1 vote
Answer accepted
Amirul Ikhwan Omar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 30, 2018

The internal error usually can happen if the json  data are not valid. Looking at your JSON value it looks like it is missing a "fields"": syntax:

{ 
"fields":{
"project":{
"key":"BUR"
},
"summary":"Testing REST API",
"issuetype":{
"name":"Task"
}
}
}

 Please add above json and try again if you are able to create issue successfully

Max October 30, 2018

Thanks bro. That worked!! :)

Max October 30, 2018

@Amirul Ikhwan Omar, Can you kindly help us with the JIRA module in python? I see these errors for a simple script. All I am trying to do is list the projects. Can you please help with this issue? As you know from above, I am able to connect to the server to GET and POST using Curl commands from command prompt. But my objective is to use the python jira module.

#!/usr/bin/python

from jira import JIRA

options = { 'server' : 'http://x.x.x.x:7070'}

jira = JIRA(options,basic_auth=('test', 'test1234!'))
projects = jira.projects()

print (projects)

C:\Dropbox\JIRA>python test_jira.py
Traceback (most recent call last):
File "req_jira2.py", line 21, in <module>
jira = JIRA(options,basic_auth=('test', 'test1234!'))
File "C:\Python3\lib\site-packages\jira\client.py", line 472, in __init__
si = self.server_info()
File "C:\Python3\lib\site-packages\jira\client.py", line 2133, in server_info
j = self._get_json('serverInfo')
File "C:\Python3\lib\site-packages\jira\client.py", line 2549, in _get_json
r = self._session.get(url, params=params)
File "C:\Python3\lib\site-packages\jira\resilientsession.py", line 151, in get
return self.__verb('GET', url, **kwargs)
File "C:\Python3\lib\site-packages\jira\resilientsession.py", line 147, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "C:\Python3\lib\site-packages\jira\resilientsession.py", line 57, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError: JiraError HTTP 404 url: http://x.x.x.x:7070/rest/api/2/serverInfo

response headers = {'Server': 'Apache-Coyote/1.1', 'Content-Length': '0', 'Date': 'Wed, 31 Oct 2018 03:55:07 GMT'}
response text =

Amirul Ikhwan Omar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 30, 2018

Hi Max, 

Looking at the reply it looks like you are using a different based URL (http://x.x.x.x:7070/issue). Based on the error it looks like the script unable to reach to the based URL (http://x.x.x.x:7070)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events