Hello Monday.com, I need your help!
I’m sending two post req from java
first req is creating ticket
second req tries to upload file(screenshot) on created_item but with no success
Below is my second req code and i also added first and second requested query datas and responses from the server.
public static String updateDefect( String itemID, File file) {
HttpURLConnection connection = null;
String targetURL = “https://levank707.monday.com/v2”;
String query3 = “{"query":"mutation{add_file_to_column(file: “+file+”, "
+ “item_id:”+itemID+”, column_id: "files") {id}}";
try {
//Create connection
URL url = new URL(targetURL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/json");
connection.setRequestProperty("Content-Type",
"multipart/form-data");
connection.setRequestProperty("Content-Length",
Integer.toString(query3.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
connection.setRequestProperty("Authorization",token );
connection.setUseCaches(false);
connection.setDoOutput(true);
//Send request
DataOutputStream wr = new DataOutputStream (
connection.getOutputStream());
wr.writeBytes(query3);
wr.close();
System.out.println("\\n\\nThe request of adding files to ticket " +"\\n\\n" + query3);
//Get Response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
StringBuilder response = new StringBuilder(); // or StringBuffer if Java version 5+
String line;
while ((line = rd.readLine()) != null) {
response.append(line);
response.append('\\r');
System.out.print("\\n\\n the response of adding files to ticket" + "\\n\\n"+ response);
}
rd.close();
return response.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (connection != null) {
connection.disconnect();
}
}
}}
reqs and responses
The request for creating ticket
{“query”:“mutation {create_item (item_name:"TestCase0got failed due to some assertion or exception. device name:iPhone11",board_id:1249501957){id}}”,“variables”:{}}
The response of created ticket
{“data”:{“create_item”:{“id”:“1260998189”}},“account_id”:8845295}
The request of adding files to ticket
{“query”:"mutation{add_file_to_column(file: /var/folders/v4/8yb367ws17945wp809g_xcgc0000gn/T/screenshot1211423245607493504.png, item_id:1260998189, column_id: “files”) {id}}
the response of adding files to ticket
{“errors”:r{“message”:“No query string was present”}],“account_id”:8845295}