要为变更添加附件文档,使用以下URL:
http://<servername>:<port number>/sdpapi/change/<change id>/attachment
假设变更ID为25,则示例URL为:
http://localhost:8080/sdpapi/change/25/attachment
关键参数:
操作名称 - 属性名称为:"OPERATION_NAME",值为:"ADD_ATTACHMENT"。
技术员密钥 - 属性名称为:"TECHNICIAN_KEY",值为:密钥的值。
注意: 输出XML的格式已经更改。
添加附件用的客户端代码示例: 以下为Java语音的示例代码: { /** * 1. Create a MultipartPostMethod * 2. Construct the web URL to connect to the SDP Server * 3. Add the filename to be attached as a parameter to the MultipartPostMethod with parameter name "filename" * 4. Execute the MultipartPostMethod * 5. Receive and process the response as required * / HttpClient client = new HttpClient( ); String weblinkURL = "http://<SDPServer>:<PortNumber>/sdpapi/change/<changeId>/attachment?OPERATION_NAME=ADD_ATTACHMENT&TECHNICIAN_KEY= MultipartPostMethod method = new MultipartPostMethod( weblinkURL ); String fileName = "C:" + File.pathSeparator + "ManageEngine" + File.pathSeparator + "ServiceDesk" + File.pathSeparator + "a.csv"; File file = new File(fileName); method.addParameter("filename", file ); try { client.executeMethod( method ); String response = method.getResponseBodyAsString(); System.out.println( response ); } catch (HttpException he) { System.out.println( he ); } catch (Exception e) { System.out.println( e ); } finally { method.releaseConnection( ); } } |
注意: 请注意 输入和输出XML的格式已经更改。
输出: <?xml version="1.0" encoding="UTF-8"?> <operation name="ADD_ATTACHMENT"> <result> <statuscode>200</statuscode> <status>Success</status> <message>Attachments added successfully</message> </result> <Details type="attachment"/> </operation> |