JIRA Service Desk REST Api Android Client when try to add comment or attachment

Hi!

I try to create Android app for Jira Service Desk and having problems with create attachment or comment - returned status : BasicNetwork.performRequest: Unexpected response code 403 for

. There are no problems with login or get list of issues, projects ect. 

After few days I have no idea where is the problem. 

I'm using Volley library to comunicating with jira rest. First step of creating attachment - create temprorary attachment returns status 201 - ok, and Json response with temp attachment id. 

It's my code here for creating attachment, can anyone help?:

public void makeAttachmentVisible(final VolleyCallback volleyCallback, final JSONObject jsonObject){
queryObject= new JSONObject();
JSONArray queryArray = new JSONArray();

try {
JSONArray jsonArray = jsonObject.getJSONArray("temporaryAttachments");
for(int i =0; i<jsonArray.length(); i++){
String id = (String) jsonArray.getJSONObject(i).get("temporaryAttachmentId");
queryArray.put(id);
}
} catch (JSONException e) {
e.printStackTrace();
}
try {
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("body","test");
queryObject.put("additionalComment",jsonObject1);
queryObject.put("public",true);
queryObject.put("temporaryAttachmentIds",queryArray);




} catch (JSONException e) {
e.printStackTrace();
}

Log.d("MyConnection",queryObject.toString());
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, MAKE_FILE_VISIBLE, queryObject, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {

}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyError volleyError = (VolleyError) error;
// NetworkResponse response = error.networkResponse;

}
}){
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> headers = new HashMap<>();
headers.put("cookie",readDataFromPreferences());
headers.put("X-ExperimentalApi", "true");
headers.put("X-Atlassian-Token", "nocheck");
// headers.put("X-AUSERNAME","test");
return headers;
}
};
requestQueue.add(jsonObjectRequest);
}

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jun 14, 2018 in Jira Service Desk

How the Telegram Integration for Jira helps Sergey's team take their support efficiency to the bank

...+ reading Fantasy). The same is true for him at the bank he works for: Efficiency is key when time literally equals money. Read on to learn how Sergey makes most of the time he has by...

790 views 5 7
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you