cuc8.5 addMember to distributionlist - bad request

Version 1
    This document was generated from CDN thread

    Created by: Sascha Monteiro on 21-02-2011 10:49:47 PM
    Hi,
    my app needs to add a user to a DL, it works from a rest client (firefox plugin),
    but when I do it from my app, I get a bad request (400 - The request sent by the client was syntactically incorrect (Bad Request).
     
    I can ldapimport users fine etc, it's just this request that fails
     
    this is the request;
    url: https://1.1.1.233:8443/vmrest/distributionlists/3960a6e3-952d-4c3b-a3d7-5c25c593dfb7/distributionlistmembers
    method: POST
    body: <DistributionListMember><MemberUserObjectId>5e29a7f3-3a3f-4ea0-8a33-1c23dd4d0f01</MemberUserObjectId></DistributionListMember>
    content-type: application/xml
     
    this is the log from the cuc;
    16:24:35.157 |17967,,,VMREST,3,DEBUG [http-8443-11] com.cisco.connection.rest.RequestFilter  - REQUEST POST distributionlists/3960a6e3-952d-4c3b-a3d7-5c25c593dfb7/distributionlistmembers
    16:24:35.188 |17967,,,VMREST,3,DEBUG [http-8443-11] com.cisco.connection.rest.ResponseFilter  - RESPONSE filter IN
     
    and this is the log when I use a rest client;
    16:24:53.935 |17967,,,VMREST,3,DEBUG [http-8443-11] com.cisco.connection.rest.RequestFilter  - REQUEST POST distributionlists/3960a6e3-952d-4c3b-a3d7-5c25c593dfb7/distributionlistmembers
    16:24:54.007 |17967,,,VMREST,3,DEBUG [http-8443-11] com.cisco.connection.rest.impl.GeneratedDistributionListMemberRestImpl  - returning session cached authentication information: alias=admin, id=f0cd8ae4-c330-4489-8e92-cf9831d85a11
    16:24:54.929 |17967,,,VMREST,3,DEBUG [http-8443-11] com.cisco.connection.rest.impl.GeneratedDistributionListMemberRestImpl  - created distributionlistmember: DistributionListMemberCreateTOImpl[memberGlobalUserDignetObjectId=null;noOpIfAlreadyExists=null;memberContactObjectId=null;distributionListObjectId=3960a6e3-952d-4c3b-a3d7-5c25c593dfb7;memberDistributionListObjectId=null;memberUserObjectId=1c78e693-1fc7-424a-ace1-49c5c0e8442d;memberGlobalUserObjectId=null;auditComponent=VMREST;objectId=b269abc3-a1ad-45b1-af32-02979e88ed0b;auditAlias=admin;]
    16:24:54.929 |17967,,,VMREST,3,DEBUG [http-8443-11] com.cisco.connection.rest.ResponseFilter  - RESPONSE filter IN
     
    there are no errors in this file, trace level (micro-vmrest) is set to all
    (file tail activelog cuc/diag_Tomcat_00000008.uc num 50)
     
    http doesn't work, so cannot capture the packets to view
     
    any ideas anyone?

    Subject: RE: cuc8.5 addMember to distributionlist - bad request
    Replied by: David Wanagel on 22-02-2011 08:44:55 AM
    An error that says "syntactically incorrect" means that the request can not be unmarshalled into a java object.  I don't spot the syntax error below, but it is hard to parse XML by eye.  How are you marshalling the XML?  Is it handwritten or generated?  You won't see any errors coming from VMREST because the error is happening before the request is processed by the web application.  The error is happening when the outer layers try to convert the XML to a java object.
     
    -Dave

    Subject: RE: cuc8.5 addMember to distributionlist - bad request
    Replied by: Sascha Monteiro on 22-02-2011 04:28:13 PM
    Hi David,
    It's all handwritten. If I copy the url and body from the debug and paste them into a rest client, it works fine.

    It's not easy to troubleshoot if the CUC server cannot produce enough debugs,
    also without it accepting http it's not possible to capture packets

    Subject: RE: cuc8.5 addMember to distributionlist - bad request
    Replied by: David Wanagel on 22-02-2011 04:42:02 PM
    You can still send the request via HTTP and capture the packets.  The server will just respond with a 302 redirecting the request to the HTTPS port.  Your client may not like the 302 response, but at least you can then look at the packets you are sending.  There is something in the XML payload that is making it invalid XML per the XSD.  It might be worth hand writing the XML in the test application in case the cut and paste is picking up some extra info somehow.  The bottom line is that the XML getting to the server is not valid.
     
    -Dave

    Subject: RE: cuc8.5 addMember to distributionlist - bad request
    Replied by: Sascha Monteiro on 22-02-2011 04:46:54 PM
    I have found the issue, there were hidden characters that didn't show up in Eclipse,
    but when I used vi from my terminal I saw ^@ at the end of the elements.
    They must have been created by XMLSpy as I used that to generate xml from the xsd