mysql - [FORMBODY参数为空?

标签 mysql json utf-8 asp.net-web-api

在使用fiddler测试时,我创建了Insert方法来使用实体将数据插入到Mysql中

我解决了这个网址,但对我不起作用 Fiddler testing API Post passing a [Frombody] class

User-Agent: Fiddler
Host: localhost:4086
Content-Length: 193
Content-type: application/json; charset=utf-8

以上格式显示集合对象为空

public class InsertController : BaseApiController
{
    static readonly IInsertMaster obj = new InsertMaster();

    [HttpPost]
    public HttpResponseMessage PostUser(collection_master collection)
    {
        if (collection == null)
            return Request.CreateResponse(HttpStatusCode.BadRequest, "not created");

        if (obj.PostUser(collection))
        {
            return Request.CreateResponse(HttpStatusCode.Created, TheModelFactory.create(collection));
        }
        else
            return Request.CreateResponse(HttpStatusCode.BadRequest, "Could not save to the database");
    }

}

输入:

 {"CustomerID":"10","AmountRecevied":1000","Date_Time":"2014-03-03 10:00:00","Area":"banglore","AgentID":"1","Money_Receipt_No":"123456","Payment_Mode":"cheque","Money_Receipt_Photo":null}

最佳答案

试试这个

   Content-type: application/json; charset=utf-8   

JSON 文本应以 Unicode 编码。默认编码为 UTF-8。

由于 JSON 文本的前两个字符始终是 ASCII 字符 [RFC0020],因此可以确定八位字节流是 UTF-8、UTF-16(BE 或 LE)还是 UTF-32(BE或 LE)通过查看前四个八位字节中的空值模式。 00 00 00 xx UTF-32BE 00xx 00xx UTF-16BE xx 00 00 00 UTF-32LE xx 00 xx 00 UTF-16LE xx xx xx xx UTF-8

在这里检查
What does "Content-type: application/json; charset=utf-8" really mean?

关于mysql - [FORMBODY参数为空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23358598/

相关文章:

php - 为什么 jQuery 使用 UTF-16 进行 POSTing?

php - 特定汉字在 http get 请求期间被错误编码

php - 如果不存在则插入php

php - 如何通过 PHP 运行 SQL 更新查询?

c# - 我可以在 Xamarin、C#、iOS 中保存对象数组(或 json 数组、字典数组)吗?

java - 出现 ' JSON EXCEPTION: no value for ' 错误?

ruby-on-rails - 如何在 ruby​​ 中使用 utf8 的正则表达式

PHP Mysql 准备语句不同的结果

php - 无法在 Laravel 中检索多个 mysql 查询值

javascript - 如何在深入分析 Highcharts 中填充动态 json 值