Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About VladimirM

  • Rank
    Level 2 Contributor

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, can I create a request with attachment with rest api? I saw an example in java code but i cant do it in c# code or type script code and I cant do it with postman some one can help me? this is the java code example: import java.io.File; import java.io.IOException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.multipart.FilePart; import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; import org.apache.commons.httpclient.methods.multipart.Part; import org.apache.commons.httpclient.methods.multipart.StringPart; import org.apache.commons.httpclient.params.HttpMethodParams; /** * This sample class demonstrates how to create a new Change Order with an attachment. * * @author valre03 * @version $Revision: ASPEN.0 $ */ public class SampleNewResourceWithAttachment { public SampleNewResourceWithAttachment() { //--- CONFIGURABLE VARIABLES // REST Web Services URI String restURI = "http://localhost:8050/caisd-rest"; // Access Key obtained during Authentication String accessKey = "1174913924"; // Attachment details String serverName = ""; // Enter valid host name String fileToAttach = "sampletext.txt"; String repositoryId = "1002"; // Service Desk default // Change Order details String requestor = "ServiceDesk"; //--- END OF CONFIGURABLE VARIABLES // Verify fileToAttach exists and is valid File binaryFile = new File(fileToAttach); if ( ! binaryFile.exists() || ! binaryFile.canRead() || ! binaryFile.isFile() ) throw new IllegalArgumentException("Invalid value provided for argument fileToAttach."); // Change Order payload String chgPayload = "<chg>" + "<requestor COMMON_NAME=\"" + requestor + "\"/>" + "<status REL_ATTR=\"APP\"/>" + "<description>Created with attachment using REST sample code</description>" + "</chg>"; // Change Order service URI with attachment (attmnt) data included String chgURI = restURI + "/chg" + "?repositoryId=" + repositoryId + "&serverName=" + serverName + "&mimeType=Text" + "&description=" + binaryFile.getName(); System.out.println("Change Order with Attachment POST URI: " + chgURI); System.out.println("Change Order payload: " + chgPayload); ////////////////////////////////////////////////////////////// // POST OPERATION -- Create a new Change Order with attachment ////////////////////////////////////////////////////////////// HttpClient client = new HttpClient(); // Set timeout (not mandatory) client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); PostMethod postChgWithAttmnt = new PostMethod(chgURI); postChgWithAttmnt.getParams().setBooleanParameter( HttpMethodParams.USE_EXPECT_CONTINUE, false ); try { // Change Order payload StringPart payloadPart = new StringPart("chg", chgPayload); payloadPart.setContentType("application/xml"); // File attachment payload FilePart binaryPart = new FilePart(binaryFile.getName(), binaryFile); binaryPart.setContentType("application/octet-stream"); Part[] parts = { payloadPart, binaryPart }; // Add the multiple parts to the POST operation postChgWithAttmnt.setRequestEntity( new MultipartRequestEntity(parts, postChgWithAttmnt.getParams())); // Add corresponding headers postChgWithAttmnt.addRequestHeader("Content-Type", "multipart/form-data"); postChgWithAttmnt.addRequestHeader("X-AccessKey", accessKey); System.out.println("Execute POST request for " + chgURI); // Execute POST request int result = client.executeMethod(postChgWithAttmnt); System.out.println("Response status code: " + result); System.out.println("Response body: "); System.out.println(postChgWithAttmnt.getResponseBodyAsString()); System.out.println(); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { postChgWithAttmnt.releaseConnection(); } } public static void main(String[] args) { new SampleNewResourceWithAttachment(); } }
  2. Hi I want to attach file to custom object what is the steps that I have to do? I kno that I need create new maj file and table but in need more details and some code for example
  3. Thanks, How I do it with object? do you have some example? I tried do it with object but it didnt work (i already nor remember why) I was born there but I live in Israel so I dont know about CIS
  4. Hi Any one knows what is mean this error? It heppens sometimes without the user doing anything.
  5. Anyone know if I can change dynamically field to Read Only with spell code? (not client side)
  6. Hi, I have a problem with the emails in SDM. The emails doesnt send from mail queue. After I kill the pdm_mail proccess it works for a few days and then stop work again. I checked the stdlog files but I not see anything. What could it be?
  7. Hi, I have a string array how can I pass this array to other function like simple values? my code is: cnt:pass_array(...) { string arr[2]; arr[0] = "x"; arr[1] = "y"; misc::my_func(arr); } misc::my_func(string arr[2]) { } but this code doesnt work.
  8. Hi, I installed 17.2 verssion and I have a Service Point Can I customize that? I want check the access type of the current user and show him the fields that he can see for example user with access type X will see 3 fields and user with access type Y will see this 3 fields + 2 anoter fields. How can I do that?
  9. I want to manage "permissions" for properties. I added a new checkbox to cr_prptpl "show_to_customer" I want check this field and if the value = 1 show the property else not show how can I do it? I checked a few files like cst_cat.js, dyn_properties.htmpl but i didnt find solution
  10. Hi, I would like to return value from function to other function. for example: cnt::z_cnt_change(...) { string desc; desc = misc::insert_desc(); logf(ERROR, format("description is: %s", desc)); } misc::insert_desc() { string log; log = "test"; return ((string)log); } I get this log: description is: 0 how can I get the value from "insert_desc" function?
  • Create New...