locked
SP1 RTM: PUT Not Working Anymore RRS feed

  • Question

  • URI:
    http://localhost:5289/Vital/Vital.svc/Invoices(33)

     

    Headers:

    Server: ASP.NET Development Server/9.0.0.0
    Date: Wed, 20 Aug 2008 11:55:41 GMT
    X-AspNet-Version: 2.0.50727
    DataServiceVersion: 1.0;
    Cache-Control: private
    Content-Type: application/json
    Content-Length: 126
    Connection: Close

     

    Request Headers:

    Host: localhost:5289
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 (.NET CLR 3.5.30729
    Accept: application/json
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    X-Requested-With: XMLHttpRequest
    Content-Type: application/json; charset=UTF-8
    Referer: http://localhost:5289/Vital/Index.html
    Content-Length: 206

     

    PUT:

    {Date: '\/Date(1219017600000)\/',Number: 'ytrewq123',Amount: '1000',Paid: '1000',Description: 'Add test number 6,561.',Explanation: 'Because I suck at programming!',Vendors:{__metadata:{uri: 'Vendors(4)'}}}

     

    Response:

    {"error": {"code": "", "message": {"lang": "en-US", "value": "An error occurred while processing this request."}}} 400

     

    Notes:

    I have IDataServiceConfiguration UseVerboseErrors set to true already.


    This same code worked perfectly before the upgrade from SP1 Beta to SP1 RTM.


    Also when I take out the key id from the URI and send the same exact JSON via a POST it works and adds a new invoice to the Invoices table.


    I am sure it's not an issue of malformed JSON.


    I zipped the source and put it here.


    Plea:

    Please help...

    Wednesday, August 20, 2008 12:19 PM

Answers

  • Hi Shawn,

     The MERGE Verb is  not supported by the xmlhttp stack in IE , try tunneling the Mege Verb through a Post by including the x-http-method header.

     

    addHeader(X-Http-Method : MERGE)

    and then POST to the  MERGE endpoint.

     

    Monday, August 25, 2008 7:41 AM
    Moderator

All replies

  • We had the same problem.  We ran into this issue when trying to update entities that had foreign key relationships.  Instead of using PUT, try using MERGE.  Note that the MERGE http method will only work in FireFox, not IE, unless you use a workaround (which we're still working on).

    Pablo made a post about possibly moving this direction a few months back.

    http://blogs.msdn.com/astoriateam/archive/2008/05/20/merge-vs-replace-semantics-for-update-operations.aspx

    Hope that helps,

    Joe
    Thursday, August 21, 2008 12:07 AM
  •  

    There are foreign key relationships in all of the places effected. Good call...
    Thursday, August 21, 2008 1:21 PM
  • Code Snippet

     

    Ext.Ajax.request
    (
     {
      url: Vital.DataServiceURL + 'Users(' + id + ')',
      method: 'MERGE',
      jsonData: jd,
      callback: function (o, success, r)
      {
       if (r.responseText == '')
       {
        s.reload();
        f.reset();
        Ext.ux.Quick.msg('Update', 'User Updated');
       } else {
        Ext.MessageBox.alert('Update', 'Error, please call the helpdesk...');
       }
      }
     }
    );

     

     

    MERGE did work in FF but not IE. FF did the update without a hitch and it projected all the way to the Table. IE choked on the MERGE verb.

     

    I need it to work in IE though; is there a work around?

    Thursday, August 21, 2008 2:23 PM
  • Anyone...

     

    Saturday, August 23, 2008 8:19 PM
  • Hi Shawn,

     The MERGE Verb is  not supported by the xmlhttp stack in IE , try tunneling the Mege Verb through a Post by including the x-http-method header.

     

    addHeader(X-Http-Method : MERGE)

    and then POST to the  MERGE endpoint.

     

    Monday, August 25, 2008 7:41 AM
    Moderator