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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Rest api Java

KN_9954684
12-Amethyst

Rest api Java

I am calling rest api(thingworx url) from java eclipse but throwing error in java.Below is my code

 

String b64 = Base64.getEncoder().encodeToString(bytes);

//Construct jsoninput body//

JSONObject params=new JSONObject();

params.put("path","/Motivation.pdf");

params.put("content", b64);

 

//Load pdf to Thingworx repository//

String url = "HiddenServerurlforsafetypurpose/Thingworx/Things/komal_FileRepo/Services/SaveBinary";

 

URL obj = new URL(url);

 

HttpURLConnection con = (HttpURLConnection) obj.openConnection();

 

//add request header

 

con.setRequestMethod("POST");

 

con.setRequestProperty("Accept", "application/json");

 

con.setRequestProperty("Content-Type", "application/json");

 

con.setRequestProperty("appKey", "removedforsafetypurpose");

 

con.setRequestProperty("Body", params.toJSONString());

 

// Send post request

 

con.setDoOutput(true);

 

DataOutputStream wr = new DataOutputStream(con.getOutputStream());

 

wr.flush();

 

wr.close();

 

int responseCode = con.getResponseCode();

 

System.out.println("\nSending 'POST' request to URL : " + url);

 

System.out.println("Response Code : " + responseCode);

 

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

 

String inputLine;

 

StringBuilder response = new StringBuilder();

 

while((inputLine = in.readLine()) != null) {

 

response.append(inputLine);

 

}

 

in.close();

 

//print result

 

System.out.println(response.toString());

 

Error in Thingworx :

 

No Path Was Specified

 

[SECURITY FAILURE Anonymous:@unknown -> /ExampleApplication/IntrusionDetector] Invalid input: context=HTTP header value: body, type(HTTPHeaderValue)=^[a-zA-Z0-9()\-=\*\.\?;,+\/:&_ %$ ¡-￿'"]*$, input={"path":"\/Motivation.pdf","content":"JVBERi0xLjQKJeLjz9MKMiAwIG9iago8PC9MZW5ndGggMTIxL0ZpbHRlci9GbGF0ZURlY29kZT4+c3RyZWFtCnicFc3LCsIwEEbh\/TzF76oKXhKF0rVQQX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3OGIxMTkwMjBjMGVkPjxjZGI0ZTJlZDgyN2M4YzZhMmYwNzhiMTE5MDIwYzBlZD5dPj4KJWlUZXh0LTUuNS4xMy4yCnN0YXJ0eHJlZgo2NTkKJSVFT0YK"}

 

If i am passing same input to the service in thingworx directly,It is generating pdf.

 

Please help me how to pass json input

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Thank you Velkumar for the much needed support.

View solution in original post

22 REPLIES 22

Hi @KN_9954684 

 

I think there is some bug in the code. You are setting Body as POST Header Property.

 

Please refer to this one -

 

POSTing via a REST call in Java - PTC Community

 

Making a JSON POST Request With HttpURLConnection | Baeldung

 

/VR

In the first example they are not setting body.

 

As per second example I set the body and changed the code but still I am getting error as "No path was specified"

 

Please check below code

 

String url = "Hiddenforsecuritypurpose/Things/komal_FileRepo/Services/SaveBinary";

 

String jsonInputString = "{"+"path"+":"+"/Motivation.pdf"+","+"content"+":"+b64+"}";

 

 

URL obj = new URL(url);

 

HttpURLConnection con = (HttpURLConnection) obj.openConnection();

 

//add request header

 

con.setRequestMethod("POST");

 

con.setRequestProperty("Accept", "application/json");

 

con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");

 

con.setRequestProperty("appKey", "Hidden");

 

//con.setRequestProperty("Body", jsonInputString);

 

 

// Send post request

 

con.setDoOutput(true);

 

// DataOutputStream wr = new DataOutputStream(con.getOutputStream());

//

// wr.flush();

//

// wr.close();

//

// int responseCode = con.getResponseCode();

//

// System.out.println("\nSending 'POST' request to URL : " + url);

//

// System.out.println("Response Code : " + responseCode);

//

// BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

//

// String inputLine;

//

// StringBuilder response = new StringBuilder();

//

// while((inputLine = in.readLine()) != null) {

//

// response.append(inputLine);

//

// }

//

// in.close();

//

// //print result

//

// System.out.println(response.toString());

try(OutputStream os = con.getOutputStream()) {

byte[] input = jsonInputString.getBytes("utf-8");

os.write(input, 0, input.length);

}

try(BufferedReader br = new BufferedReader(

new InputStreamReader(con.getInputStream(), "utf-8"))) {

StringBuilder response = new StringBuilder();

String responseLine = null;

while ((responseLine = br.readLine()) != null) {

response.append(responseLine.trim());

}

System.out.println(response.toString());

}

Hi @KN_9954684 

 

Please find below code 

 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class restApiPostRequest {

	public static void main(String[] args) throws IOException {

		// Create URL Instance
		URL url = new URL("http://192.168.86.195:8080/Thingworx/Things/SystemRepository/Services/SaveBinary");

		// Open Connection
		HttpURLConnection conection = (HttpURLConnection) url.openConnection();
		// set HTTP Method
		conection.setRequestMethod("POST");

		// Set Headers to specify content types
		conection.setRequestProperty("Content-Type", "application/json");
		conection.setRequestProperty("Accept", "application/json");
        conection.setRequestProperty("appKey", "2d3571aa-8d70-40ad-b1be-2a32ebb69a1a");
		
		// to enable write content to request
		conection.setDoOutput(true);
		
		// making JSON String
		String jsonString = "{ \"content\": \"JVBERi0xLjQKJeLjz9MKMiAwIG9iago8PC9MZW5ndGggMTIxL0ZpbHRlci9GbGF0ZURlY29kZT4+c3RyZWFtCnicFc3LCsIwEEbh\\/TzF76oKXhKF0rVQQXfCvEAwE6uFjk1SxLc32Z3FB2emM9OpRWdasCeDne1qHC4W9ggOtL4G\\/HRpokBDkCgeDklchk6loj5GyUjD67OF16nJcGnEdyigqhVuS8p4SvX7Db\\/Lw9RDz3SnP8DJJHoKZW5kc3RyZWFtCmVuZG9iago0IDAgb2JqCjw8L1R5cGUvUGFnZS9NZWRpYUJveFswIDAgNTk1IDg0Ml0vUmVzb3VyY2VzPDwvRm9udDw8L0YxIDEgMCBSPj4+Pi9Db250ZW50cyAyIDAgUi9QYXJlbnQgMyAwIFI+PgplbmRvYmoKMSAwIG9iago8PC9UeXBlL0ZvbnQvU3VidHlwZS9UeXBlMS9CYXNlRm9udC9IZWx2ZXRpY2EvRW5jb2RpbmcvV2luQW5zaUVuY29kaW5nPj4KZW5kb2JqCjMgMCBvYmoKPDwvVHlwZS9QYWdlcy9Db3VudCAxL0tpZHNbNCAwIFJdPj4KZW5kb2JqCjUgMCBvYmoKPDwvVHlwZS9DYXRhbG9nL1BhZ2VzIDMgMCBSPj4KZW5kb2JqCjYgMCBvYmoKPDwvUHJvZHVjZXIoaVRleHSuIDUuNS4xMy4yIKkyMDAwLTIwMjAgaVRleHQgR3JvdXAgTlYgXChBR1BMLXZlcnNpb25cKSkvQ3JlYXRpb25EYXRlKEQ6MjAyMzEwMDQxNjE2MzkrMDUnMzAnKS9Nb2REYXRlKEQ6MjAyMzEwMDQxNjE2MzkrMDUnMzAnKT4+CmVuZG9iagp4cmVmCjAgNwowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAzMTUgMDAwMDAgbiAKMDAwMDAwMDAxNSAwMDAwMCBuIAowMDAwMDAwNDAzIDAwMDAwIG4gCjAwMDAwMDAyMDMgMDAwMDAgbiAKMDAwMDAwMDQ1NCAwMDAwMCBuIAowMDAwMDAwNDk5IDAwMDAwIG4gCnRyYWlsZXIKPDwvU2l6ZSA3L1Jvb3QgNSAwIFIvSW5mbyA2IDAgUi9JRCBbPGNkYjRlMmVkODI3YzhjNmEyZjA3OGIxMTkwMjBjMGVkPjxjZGI0ZTJlZDgyN2M4YzZhMmYwNzhiMTE5MDIwYzBlZD5dPj4KJWlUZXh0LTUuNS4xMy4yCnN0YXJ0eHJlZgo2NTkKJSVFT0YK\", \"path\": \"/motivation.pdf\" }";

        try (OutputStream os = conection.getOutputStream()) {
            byte[] input = jsonString.getBytes(StandardCharsets.UTF_8);
            os.write(input, 0, input.length);
        }
        
        // Print Stataus code
        System.out.println("Status Code: "+conection.getResponseCode());

        // Get content from response and print in console. Use try with resource to close streams automatically
        try (BufferedReader br = new BufferedReader(new InputStreamReader(conection.getInputStream(), StandardCharsets.UTF_8))) {
            StringBuilder resp = new StringBuilder();
            String respLine = null;
            while ((respLine = br.readLine()) != null) {
                resp.append(respLine.trim());
            }
            
            System.out.println(resp.toString());
        }
	}
}

 

 

/VR

Thanks for the reply.

 

I see that you have given the content and path directly in json string.

 

I am fetching content value from a variable , So I have written code like below which is not throwing any errors nor creating the file.

 

JSONObject params=new JSONObject();

params.put("path","komal_FileRepo/Motivation.pdf");

params.put("content", b64);

 

String jsonString = params.toString();

 

And rest of the code is similiar to yours.

 

When I print the jsonString variable in eclipse,It is like below unlike yours

 

jsonString{"path":"komal_FileRepo/Motivation.pdf","content":"JVBERi0xLjQKJeLjz9MKMiAwIG9iago8PC9MZW5ndGggNjE1L0ZpbHRlci9GbGF0ZURlY29kZT4+c3RyZWFtCnic5ZZPb9pAEMXvfIo5oeQA2CRFTm4pJSqqolDF7QkpWuyxvfHujrO7rsu375h/SqS0KE56aU+ADW9mf/PemMfex7h3NoEomECc9gIYhFH7ZnQdQjiGOOudhBfRWXQaP/DN4Nl3Tm6lgkwqJU0O0nhRIiSiAosp3A5se7Wy6NAkfL3ApHxRpPC+cpejUe0a2YRhNB6WVCi0CQ0T0pfR+fnZKC5YrCH7c3SDqRQz46WX6EaxzNHefyEt1P1c5++uf1ebTFFztMbvEV1Ju0eTC1ei/1+QvKXGAkVCSfnXoA9fqTczrrb8W7IWEw9z88AvZNn7XqPxIBxUaEFTiqqj9q7PFfoG0cDKovAFa1ayQujvTvPGvq/nC1iezD4FweTDRTAJw2B5yr071CvFkSUDaHJp2nqa22nzy9ek71i2Lbci5aFAkYIhD6nQIse0o15lqaW8h04ZXH0f3KFQsFpDIUxX3QPrghx/Il9AooSuwBVUq5Rn8hwSW6linPIHgqJEeEnGDRnstHaeNNoXa01JV0rwGJen3Wl6Ait4535ebH3BHnysuamOtlDkNjtaCc9H9JAha1U1n7yRDGFnyT40wjGel+n+C6vqKCnHJhNsudbDXHUTjJp5WdLgWl59yFFYfvhtgDLK3fZxMu0a2pvFN65rHK+ZnJ+p+8UQDMeDYBiB1p1TtNuEnJ8nXULKzjLshTrfTj+hqk3bn2Z/tFam1k2ByH8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ZgowIDExCjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMTg0OCAwMDAwMCBuIAowMDAwMDAwMDE1IDAwMDAwIG4gCjAwMDAwMDE5MzYgMDAwMDAgbiAKMDAwMDAwMDY5NyAwMDAwMCBuIAowMDAwMDAwODA5IDAwMDAwIG4gCjAwMDAwMDE0NTAgMDAwMDAgbiAKMDAwMDAwMTU2MiAwMDAwMCBuIAowMDAwMDAxNzM2IDAwMDAwIG4gCjAwMDAwMDE5OTkgMDAwMDAgbiAKMDAwMDAwMjA0NCAwMDAwMCBuIAp0cmFpbGVyCjw8L1NpemUgMTEvUm9vdCA5IDAgUi9JbmZvIDEwIDAgUi9JRCBbPDUyNGY0MjMxYjE3NTU3OTdjODQwMjI0MTM3ZGRmYjY0Pjw1MjRmNDIzMWIxNzU1Nzk3Yzg0MDIyNDEzN2RkZmI2ND5dPj4KJWlUZXh0LTUuNS4xMy4yCnN0YXJ0eHJlZgoyMjA1CiUlRU9GCg=="}Status Code: 200

{}

 

Can you please let me know how to construct the json input when using variable.Thanks in advance.

Thank you ,It works

 

I have used variable for content part like below

 

String jsonString = "{\"content\" : \""+b64+"\" ,\"path\": \"/Motivation.pdf\"}";

Hi @KN_9954684 

 

I can status code: 200 which means the file got created in Thingowrx. Please check the Repository for the file.

 

It should be available in repository under folder komal_repo

 

Velkumar_0-1696584438652.png

 

/VR

 

 

Yes it is, when tried with java code.But when I executed same with Thingworx code.getting error as below

 

Active Directory error occurred. [explanation: javax.naming.CommunicationException: localhost:389 [Root exception is java.net.ConnectException: Connection refused: connect]]

 

And file is also not getting created in repository.Any idea upon this?

Please post some screenshot

KN_9954684_0-1696594061330.png

After exectuing savebinary service,I got the error 

Hi @KN_9954684 

 

There is some connectivity issue between AD and other systems. This is not related to a script error.

 

/VR

Thank you for the clarification.

 

Could you let me know if there is any way to resolve this?

Debbuging the issue.I will accept it as solution once resolved.Thanks

The Active directory error is not related to this.Can you run the same code from Thingworx as extension and let me know if pdf is getting created

 

ThingWorx 9.2.1-b112

 

Thank you.

import com.thingworx.logging.LogUtilities;
import com.thingworx.metadata.annotations.ThingworxBaseTemplateDefinition;
import com.thingworx.metadata.annotations.ThingworxPropertyDefinition;
import com.thingworx.metadata.annotations.ThingworxPropertyDefinitions;
import com.thingworx.metadata.annotations.ThingworxServiceDefinition;
import com.thingworx.metadata.annotations.ThingworxServiceParameter;
import com.thingworx.metadata.annotations.ThingworxServiceResult;
import java.io.FileNotFoundException;  
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.*;
import org.slf4j.Logger;
import com.itextpdf.text.Document;  
import com.itextpdf.text.DocumentException;  
import com.itextpdf.text.Paragraph;  
import com.itextpdf.text.pdf.PdfWriter;  
import com.thingworx.things.Thing;
import org.json.*;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import java.net.*;
import java.util.*;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
 
 
@ThingworxBaseTemplateDefinition(name = "GenericThing")
public class PDFThingTemplate extends Thing {
 
private static Logger _logger = LogUtilities.getInstance().getApplicationLogger(PDFThingTemplate.class);
 
public PDFThingTemplate() {
 
 
}
 
@ThingworxServiceDefinition(name = "Createpdf", description = "", category = "", isAllowOverride = false, aspects = {
"isAsync:false" })
@ThingworxServiceResult(name = "Result", description = "", baseType = "STRING", aspects = {})
public String Createpdf(
@ThingworxServiceParameter(name = "Mat_Info", description = "", baseType = "JSON", aspects = {
"defaultValue:{\"rows\":[{\"FileRepoUrl\":\"url/Thingworx/Things/komal_FileRepo\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":1,\"InspectionCheckList_ID\":2,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Oil filling intake cap red O-ring presence check\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":2,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Oil filling cap\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"Inspection_01.png\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\",\"Images\":[\"url/Thingworx/MediaEntities/Tiger_Komal_Img\",\"url/Thingworx/MediaEntities/Sunflower_Komal_Img\"]},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":2,\"InspectionCheckList_ID\":3,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Air intake gasket presence check\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":3,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Air intake gasket\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"Inspection_02.PNG\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\",\"Images\":[\"url/Thingworx/MediaEntities/Tiger_Komal_Img\",\"url/Thingworx/MediaEntities/Sunflower_Komal_Img\",\"url/Thingworx/MediaEntities/Peacock_Komal_Img\"]},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":3,\"InspectionCheckList_ID\":5,\"Status_ID\":1009,\"PicMaxQty\":1,\"CheckListDescription\":\"Air intake gasket presence check.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":4,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Air intake gasket\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":true,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"3.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":4,\"InspectionCheckList_ID\":6,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure correct Injector fitment as per model.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":5,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Injector \",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"3.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":5,\"InspectionCheckList_ID\":7,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure gasket between breather pipe & intake.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":6,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Breather pipe gasket\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"4.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"NOK\",\"CheckListSequence\":6,\"InspectionCheckList_ID\":8,\"Status_ID\":1010,\"PicMaxQty\":1,\"CheckListDescription\":\"Ensure correct FIP (ED0065906110) assembled on engine & masking on it.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":7,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"FIP\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":true,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"5.png\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":7,\"InspectionCheckList_ID\":9,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure FIP bolt head not damaged.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":8,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"FIP Bolt\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"6.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":8,\"InspectionCheckList_ID\":10,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure proper fitment of AV-Seal by hand.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":9,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Fitment of AV seal\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"7.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":9,\"InspectionCheckList_ID\":11,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure breather hose both clamp should be assembled on respective locations. (Customer Complaint)\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":10,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Breather hose clamp \",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"8.jpg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":10,\"InspectionCheckList_ID\":12,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure FIP to rail HP pipe torqued \",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":11,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"HP Pipe\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"9.jpg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":11,\"InspectionCheckList_ID\":13,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure closing plate at feed pump with gasket & washer.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":12,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Closing Plate\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"10.png\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\",\"Images\":[\"url/Thingworx/MediaEntities/Tiger_Komal_Img\",\"url/Thingworx/MediaEntities/Sunflower_Komal_Img\"]},{\"Material_ID\":19838,\"Status\":\"NOK\",\"CheckListSequence\":12,\"InspectionCheckList_ID\":14,\"Status_ID\":1010,\"PicMaxQty\":2,\"CheckListDescription\":\"Ensure sealant not coming out from sump & gear casing at intake side.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":13,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Oil sump & Gear casing sealant\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":true,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"11.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":13,\"InspectionCheckList_ID\":15,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure MPU sensor gap between 0.2-0.8 mm.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":14,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"MPU sensor\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"11.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"NOK\",\"CheckListSequence\":14,\"InspectionCheckList_ID\":16,\"Status_ID\":1010,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure presence of intake side drain plug with copper washer.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":15,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Intake oil drain plug\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"12.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":15,\"InspectionCheckList_ID\":17,\"Status_ID\":1009,\"PicMaxQty\":1,\"CheckListDescription\":\"Ensure flywheel for damage mark & rusty.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":16,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Flywheel\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":true,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"13.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":16,\"InspectionCheckList_ID\":18,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Check all threading of flywheel.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":17,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Flywheel threading\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"14.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":17,\"InspectionCheckList_ID\":19,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure presence of backplate with no damage & outer holes with threading\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":18,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Backplate\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"15.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":18,\"InspectionCheckList_ID\":20,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure correct engine number plate with correct engine serial number & K number as well as barcode.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":19,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Engine number plate & Barcode\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"15.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"NOK\",\"CheckListSequence\":19,\"InspectionCheckList_ID\":21,\"Status_ID\":1010,\"PicMaxQty\":1,\"CheckListDescription\":\"Ensure masking cap on exhaust elbow.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":20,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Exhaust elbow cap\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":true,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"16.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":20,\"InspectionCheckList_ID\":22,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure alternator with proper wire connection.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":21,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Alternator\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"17.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"NOK\",\"CheckListSequence\":21,\"InspectionCheckList_ID\":23,\"Status_ID\":1010,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure small spacer at alternator upper bolt and Big spacer at bottam side bolt. Ensure alternator spacer is properly tightened.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":22,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Alternator spacer\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"18.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":22,\"InspectionCheckList_ID\":24,\"Status_ID\":1009,\"PicMaxQty\":1,\"CheckListDescription\":\"Ensure coolant plug is torqued with copper washer.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":23,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"coolant plug\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":true,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"21.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":23,\"InspectionCheckList_ID\":25,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure presence of dipstick.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":24,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Dipstick\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"23.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":24,\"InspectionCheckList_ID\":26,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure oil filter for no damage & it should be on exhaust side.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":25,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Oil filter \",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"24.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":25,\"InspectionCheckList_ID\":27,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure starter motor of 2.2 kw\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":26,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Starter motor\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"25.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":26,\"InspectionCheckList_ID\":28,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure drain plug is tight with washer & marking on it.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":27,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Exhuast oil drain plug\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"26.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"NOK\",\"CheckListSequence\":27,\"InspectionCheckList_ID\":29,\"Status_ID\":1010,\"PicMaxQty\":1,\"CheckListDescription\":\"Ensure Fan pulley plate orientation should be as pr 3D drawing.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":28,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Fan pulley plate\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":true,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"28.jpg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":28,\"InspectionCheckList_ID\":30,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure wire harness routing should be over the thermostat cover.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":29,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Thermostat Cover\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"29.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":29,\"InspectionCheckList_ID\":31,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure masking cap on thermostat.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":30,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Wire harness routing & Thermostat Masking cap\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"30.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":30,\"InspectionCheckList_ID\":32,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure coolant temp sensor torqued with copper washer.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":31,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Coolant temperature senor - 1\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"31.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"NOK\",\"CheckListSequence\":31,\"InspectionCheckList_ID\":33,\"Status_ID\":1010,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure Coolant Temperature sensor wire connected.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":32,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Coolant temperature senor - 2\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"32.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"NOK\",\"CheckListSequence\":32,\"ImagesPath\":\"\\\\\\\\inaufs01\\\\Apps\\\\Thingworx\\\\InspectionImages\\\\5309301566/33_5309301566\",\"InspectionCheckList_ID\":34,\"Status_ID\":1010,\"PicMaxQty\":2,\"CheckListDescription\":\"Ensure alternator belt tension (125-147)HZ\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":33,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Belt tension\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":true,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"33.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":33,\"InspectionCheckList_ID\":35,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure no damage mark on casing cover\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":34,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Casing cover\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"34.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":34,\"InspectionCheckList_ID\":36,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure marking on VD pulley & no dent on pulley.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":35,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"VD pulley\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"35.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":35,\"InspectionCheckList_ID\":37,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure by-pass hose pipe is not damaged or pinched.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":36,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"water bypass hose\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"36.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":36,\"InspectionCheckList_ID\":38,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure marking on fan pulley with spacer.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":37,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"Fan pulley \",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"37.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":37,\"InspectionCheckList_ID\":39,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure oil cap black O-ring & no burr/paint on cap area\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":38,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"RA cover oil filling cap\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"38.jpeg\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"},{\"Material_ID\":19838,\"Status\":\"OK\",\"CheckListSequence\":38,\"InspectionCheckList_ID\":40,\"Status_ID\":1009,\"PicMaxQty\":0,\"CheckListDescription\":\"Ensure rocker cover is no damaged from all side.\",\"Material\":\"ED750034CP00000-00\",\"Data_ID\":39,\"InsertTime\":\"2023-09-29 16:27:29.1233333 +00:00\",\"CheckListName\":\"RA cover\",\"IGChecklistMaterialLink_ID\":8,\"PicRequired\":false,\"UpdatedBy\":\"KO143C2\",\"Serial\":\"5309301566\",\"InspectionGroup_ID\":2,\"SOPUrl\":\"Inspection_03.PNG\",\"LastUpdated\":\"2023-09-29 16:27:29.1233333 +00:00\",\"InspectionGroup\":\"Cargotec Buyoff\"}],\"dataShape\":{\"fieldDefinitions\":{\"Material_ID\":{\"name\":\"Material_ID\",\"aspects\":{},\"description\":\"Material_ID\",\"baseType\":\"INTEGER\",\"ordinal\":2},\"Status\":{\"name\":\"Status\",\"aspects\":{},\"description\":\"Status\",\"baseType\":\"STRING\",\"ordinal\":15},\"CheckListSequence\":{\"name\":\"CheckListSequence\",\"aspects\":{},\"description\":\"CheckListSequence\",\"baseType\":\"INTEGER\",\"ordinal\":8},\"ImagesPath\":{\"name\":\"ImagesPath\",\"aspects\":{},\"description\":\"ImagesPath\",\"baseType\":\"STRING\",\"ordinal\":16},\"InspectionCheckList_ID\":{\"name\":\"InspectionCheckList_ID\",\"aspects\":{},\"description\":\"InspectionCheckList_ID\",\"baseType\":\"INTEGER\",\"ordinal\":7},\"Status_ID\":{\"name\":\"Status_ID\",\"aspects\":{},\"description\":\"Status_ID\",\"baseType\":\"INTEGER\",\"ordinal\":14},\"PicMaxQty\":{\"name\":\"PicMaxQty\",\"aspects\":{},\"description\":\"PicMaxQty\",\"baseType\":\"INTEGER\",\"ordinal\":12},\"CheckListDescription\":{\"name\":\"CheckListDescription\",\"aspects\":{},\"description\":\"CheckListDescription\",\"baseType\":\"STRING\",\"ordinal\":10},\"Material\":{\"name\":\"Material\",\"aspects\":{},\"description\":\"Material\",\"baseType\":\"STRING\",\"ordinal\":3},\"JsonTag\":{\"name\":\"JsonTag\",\"aspects\":{},\"description\":\"JsonTag\",\"baseType\":\"STRING\",\"ordinal\":20},\"Data_ID\":{\"name\":\"Data_ID\",\"aspects\":{},\"description\":\"Data_ID\",\"baseType\":\"INTEGER\",\"ordinal\":0},\"InsertTime\":{\"name\":\"InsertTime\",\"aspects\":{},\"description\":\"InsertTime\",\"baseType\":\"STRING\",\"ordinal\":17},\"CheckListName\":{\"name\":\"CheckListName\",\"aspects\":{},\"description\":\"CheckListName\",\"baseType\":\"STRING\",\"ordinal\":9},\"IGChecklistMaterialLink_ID\":{\"name\":\"IGChecklistMaterialLink_ID\",\"aspects\":{},\"description\":\"IGChecklistMaterialLink_ID\",\"baseType\":\"INTEGER\",\"ordinal\":6},\"PicRequired\":{\"name\":\"PicRequired\",\"aspects\":{},\"description\":\"PicRequired\",\"baseType\":\"BOOLEAN\",\"ordinal\":11},\"UpdatedBy\":{\"name\":\"UpdatedBy\",\"aspects\":{},\"description\":\"UpdatedBy\",\"baseType\":\"STRING\",\"ordinal\":19},\"Serial\":{\"name\":\"Serial\",\"aspects\":{},\"description\":\"Serial\",\"baseType\":\"STRING\",\"ordinal\":1},\"InspectionGroup_ID\":{\"name\":\"InspectionGroup_ID\",\"aspects\":{},\"description\":\"InspectionGroup_ID\",\"baseType\":\"INTEGER\",\"ordinal\":4},\"SOPUrl\":{\"name\":\"SOPUrl\",\"aspects\":{},\"description\":\"SOPUrl\",\"baseType\":\"STRING\",\"ordinal\":13},\"LastUpdated\":{\"name\":\"LastUpdated\",\"aspects\":{},\"description\":\"LastUpdated\",\"baseType\":\"STRING\",\"ordinal\":18},\"InspectionGroup\":{\"name\":\"InspectionGroup\",\"aspects\":{},\"description\":\"InspectionGroup\",\"baseType\":\"STRING\",\"ordinal\":5}}}}" }) JSONObject Mat_Info) {
_logger.trace("Entering Service: Createpdf");
Document doc = new Document(); 
String jsn_FileRepo_url=null;
try {
 
PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("Motivation.pdf"));  
//opens the PDF  
doc.open();
 
JSONArray jsonArray = (JSONArray) Mat_Info.get("rows"); 
 
for (int i = 1; i <jsonArray.length();i++) {  
JSONObject jsn = (JSONObject) jsonArray.get(i);
if(jsn.has("Material_ID")) {
String mat_id = ((Integer) jsn.get("Material_ID")).toString(); 
Paragraph paraMat = new Paragraph(mat_id); 
     doc.add(paraMat);
}
     
if(jsn.has("CheckListDescription")) {
     String checklist_desc = (String) jsn.get("CheckListDescription"); 
Paragraph paraCheck = new Paragraph(checklist_desc); 
     doc.add(paraCheck);
}
 
if(jsn.has("Images")) {
JSONArray jsnImg= (JSONArray) jsn.get("Images");
for (int j = 0; j <jsnImg.length();j++) {  
String Img_url =  (String) jsnImg.get(j);
Paragraph paraImg = new Paragraph(Img_url); 
     doc.add(paraImg);
}
 
}
     
}
jsn_FileRepo_url = ((JSONObject) jsonArray.get(0)).getString("FileRepoUrl");
//String Result = (String) jsn_FileRepo_url.get("FileRepoUrl");
String Result = "";
String kp ="abc";
 
//close the PDF file  
doc.close();  
//closes the writer  
writer.close();
//Covert pdf to base64//
File file = new File("Motivation.pdf");
byte [] bytes = Files.readAllBytes(file.toPath());
String b64 = Base64.getEncoder().encodeToString(bytes);
//Construct jsoninput body//
JSONObject params=new JSONObject(); 
params.put("path","/Motivation.pdf");
params.put("content", b64); 
_logger.trace("Base64 string: "+b64);
URL url = new URL("url/Thingworx/Things/SystemRepository/Services/SaveBinary");
 
HttpURLConnection conection = (HttpURLConnection) url.openConnection();
 
conection.setRequestMethod("POST");
 
// Set Headers to specify content types
     conection.setRequestProperty("Content-Type", "application/json");
conection.setRequestProperty("Accept", "application/json");
     conection.setRequestProperty("appKey", "hidden");
     
     conection.setDoOutput(true);
     String jsonString = "{\"content\" : \""+b64+"\" ,\"path\": \"/Motivation.pdf\"}";
     try (OutputStream os = conection.getOutputStream()) {
            byte[] input = jsonString.getBytes(StandardCharsets.UTF_8);
            os.write(input, 0, input.length);
        }
        
        // Print Stataus code
        System.out.println("Status Code: "+conection.getResponseCode());
        _logger.trace("Status code1: "+conection.getResponseCode());
 
        // Get content from response and print in console. Use try with resource to close streams automatically
        try (BufferedReader br = new BufferedReader(new InputStreamReader(conection.getInputStream(), StandardCharsets.UTF_8))) {
            StringBuilder resp = new StringBuilder();
            String respLine = null;
            while ((respLine = br.readLine()) != null) {
                resp.append(respLine.trim());
            }
            
            System.out.println(resp.toString());
        }
 
}catch (Exception e) {
e.printStackTrace();
}
 
_logger.trace("Exiting Service: Createpdf");
return jsn_FileRepo_url;
}
 
}

 

//Above is my Thingworx extension code.It is not saving file to sysrepo when executed.And no error is generated.Can you import and check the same.Thanks in advance

I have imported in 9.2.5 Thingworx with http url which worked.But we want this on https and 9.2.1.Please verify the same.Thanks

Hi @KN_9954684 

 

Article - CS219756 - Using the Eclipse IDE to debug an Extension running in ThingWorx (ptc.com) You can use eclipse to debug an extension in Thingworx.

 

Also please upload your script as file or use code formatting it is difficult to copy and test it

 

/VR

Please find the attached file.

Hi @KN_9954684 

 

Please provide a proper PDF file path. The code working properly on my end

 

 

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Base64;

public class restApiPostRequest {

	public static void main(String[] args) throws IOException {

        // Convert PDF to binary
        File file = new File("C:\\test.pdf");
        byte[] bytes = Files.readAllBytes(file.toPath());
        String b64 = Base64.getEncoder().encodeToString(bytes);

		// Create URL Instance
		URL url = new URL("http://192.168.86.136:8080/Thingworx/Things/SystemRepository/Services/SaveBinary");

		// Open Connection
		HttpURLConnection conection = (HttpURLConnection) url.openConnection();
		// set HTTP Method
		conection.setRequestMethod("POST");

		// Set Headers to specify content types
		conection.setRequestProperty("Content-Type", "application/json");
		conection.setRequestProperty("Accept", "application/json");
        conection.setRequestProperty("appKey", "20e2fe8a-3a0b-4e9c-bcb7-a632f2c4a7a7");
		
		// to enable write content to request
		conection.setDoOutput(true);
		/* 
		// making JSON String
        JSONObject params = new JSONObject();
        params.put("path","/komal_FileRepo/Motivation.pdf");
        params.put("content", "JVBERi0xLjQKJeLjz9MKMiAwIG9iago8PC9MZW5ndGggMTIxL0ZpbHRlci9GbGF0ZURlY29kZT4+c3RyZWFtCnicFc3LCsIwEEbh\\\\/TzF76oKXhKF0rVQQXfCvEAwE6uFjk1SxLc32Z3FB2emM9OpRWdasCeDne1qHC4W9ggOtL4G\\\\/HRpokBDkCgeDklchk6loj5GyUjD67OF16nJcGnEdyigqhVuS8p4SvX7Db\\\\/Lw9RDz3SnP8DJJHoKZW5kc3RyZWFtCmVuZG9iago0IDAgb2JqCjw8L1R5cGUvUGFnZS9NZWRpYUJveFswIDAgNTk1IDg0Ml0vUmVzb3VyY2VzPDwvRm9udDw8L0YxIDEgMCBSPj4+Pi9Db250ZW50cyAyIDAgUi9QYXJlbnQgMyAwIFI+PgplbmRvYmoKMSAwIG9iago8PC9UeXBlL0ZvbnQvU3VidHlwZS9UeXBlMS9CYXNlRm9udC9IZWx2ZXRpY2EvRW5jb2RpbmcvV2luQW5zaUVuY29kaW5nPj4KZW5kb2JqCjMgMCBvYmoKPDwvVHlwZS9QYWdlcy9Db3VudCAxL0tpZHNbNCAwIFJdPj4KZW5kb2JqCjUgMCBvYmoKPDwvVHlwZS9DYXRhbG9nL1BhZ2VzIDMgMCBSPj4KZW5kb2JqCjYgMCBvYmoKPDwvUHJvZHVjZXIoaVRleHSuIDUuNS4xMy4yIKkyMDAwLTIwMjAgaVRleHQgR3JvdXAgTlYgXChBR1BMLXZlcnNpb25cKSkvQ3JlYXRpb25EYXRlKEQ6MjAyMzEwMDQxNjE2MzkrMDUnMzAnKS9Nb2REYXRlKEQ6MjAyMzEwMDQxNjE2MzkrMDUnMzAnKT4+CmVuZG9iagp4cmVmCjAgNwowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAzMTUgMDAwMDAgbiAKMDAwMDAwMDAxNSAwMDAwMCBuIAowMDAwMDAwNDAzIDAwMDAwIG4gCjAwMDAwMDAyMDMgMDAwMDAgbiAKMDAwMDAwMDQ1NCAwMDAwMCBuIAowMDAwMDAwNDk5IDAwMDAwIG4gCnRyYWlsZXIKPDwvU2l6ZSA3L1Jvb3QgNSAwIFIvSW5mbyA2IDAgUi9JRCBbPGNkYjRlMmVkODI3YzhjNmEyZjA3OGIxMTkwMjBjMGVkPjxjZGI0ZTJlZDgyN2M4YzZhMmYwNzhiMTE5MDIwYzBlZD5dPj4KJWlUZXh0LTUuNS4xMy4yCnN0YXJ0eHJlZgo2NTkKJSVFT0YK");
        */
		String jsonString = "{ \"content\": \"" + b64 + "\", \"path\": \"komal_repo/Motivation.pdf\" }";

        try (OutputStream os = conection.getOutputStream()) {
            byte[] input = jsonString.getBytes(StandardCharsets.UTF_8);
            os.write(input, 0, input.length);
        }
        
        // Print Stataus code
        System.out.println("Status Code: "+conection.getResponseCode());

        // Get content from response and print in console. Use try with resource to close streams automatically
        try (BufferedReader br = new BufferedReader(new InputStreamReader(conection.getInputStream(), StandardCharsets.UTF_8))) {
            StringBuilder resp = new StringBuilder();
            String respLine = null;
            while ((respLine = br.readLine()) != null) {
                resp.append(respLine.trim());
            }
            
            System.out.println(resp.toString());
        }
	}
}

 

 

ResultResult

 

Velkumar_0-1697111515118.png

 

PS : Tested in Thingworx 9.2.0

 

/VR

 

 

Thank you.Can you confirm if you have tried on https?

Yes @KN_9954684 

Thank you Velkumar for the much needed support.

Top Tags