Forums

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

Error when trying to get property from request type API

Vanessa Conceição de Sousa June 4, 2020

I'm getting error 400 when trying to get property from request type.

Already tried to authenticate with an encodedBase64 user and password, but it didn't worked.

 

Code:

 

def username = "user"
def password = "token"
String credentials = username + ":" + password
def auth = "Basic " + credentials.bytes.encodeBase64().toString()

//String encoded = credentials.bytes.encodeBase64().toString()

def response = get("rest/servicedeskapi/servicedesk/99/requesttype/2141/property" + token_appender)
.header("cache-control", "no-cache")
.asObject(Map)
.body


//Import library clone attachments
import org.apache.http.entity.ContentType;

// Begin - Imports just to generate debud
import org.apache.log4j.Logger
import org.apache.log4j.Level
// End - Imports just to generate debud

// Only for test
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
// Only for test

def issuekey = 'SDQ-1'

def result = get('/rest/api/2/issue/' + issuekey)
.header('Content-Type', 'application/json')
.asObject(Map)

def requestType = get ('/rest/servicedeskapi/request/'+ issuekey)
.header('Content-Type', 'application/json')
.asObject(Map)

def projectKey = result.body.fields.project.key

def requestTypeId = requestType.body.requestTypeId

def propertyKeyResult = get('rest/servicedeskapi/servicedesk/99/requesttype/2184/property')
.header('Content-Type', 'application/json')
.header('X-ExperimentalApi', 'opt-in')
.basicAuth('Authorization', auth )
.header("cache-control", "no-cache")
.asObject(Map)
.body

 

API documentation: https://developer.atlassian.com/cloud/jira/service-desk/rest/#api-rest-servicedeskapi-servicedesk-serviceDeskId-requesttype-requestTypeId-property-get

 

with Postman it works fine.

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events