How to POST XML using Fiddler to ASP.NET WebAPI

后端 未结 4 916
夕颜
夕颜 2021-01-06 07:39

Given the following ASP.NET WebAPI, I am trying to send a test POST using Fiddler, but can\'t get it to work. Whatever I send, I always just see the No data sent to ser

4条回答
  •  既然无缘
    2021-01-06 07:53

    For those who have the ability to do this when faced with the same issue, another option is to use JSON. I am a huge fan of XML, but unfortunately, it seems things are far more stacked against XML's usage in scenarios like this, because in this case, the standard WebApi parser requires all that hideous extra stuff, including intimate knowledge of backend namespaces and types, as well as a full XML spec namespace (* see rant below).

    {
      "SomeData": "R2D2",
      "UserName": "Johny",
      "Password": "password",
      "Num": 1013,  
      "IsCool": true
    }
    

    *( Rant, please ignore if you want to: Why require this, oh ye good gentleman who made WepApi and other such frameworks? why not allow the XML to be liberated, freely receivable without all this 'ugly'? If included, it could still specify something useful, if one needs to, but why must the rest of us include this ugliness? It seems things have been (arbitrarily, though perhaps more for historical baggage reasons, sorry you poor XML creature, you're stuck with yesterday's baggage though it need not be) stacked against XML's usage, including that, even with all this, a standard parser likely would not allow you to post the XML with the values as XML attributes. )

提交回复
热议问题