如何在android应用程序中为woo商务网站创建客户?

如何在android应用程序中为woo商务网站创建客户?,android,woocommerce,Android,Woocommerce,我做了与woo commerce的所有连接,我的产品和所有东西都被正确提取,但当我创建客户时,它会给我一个缺少参数数据的错误 aQuery = new AQuery(context); HashMap<String, String> stringStringHashMap = new HashMap<>(); String url = WooCommerceAuthentication.getUrl("POST&", "customers", stringStr

我做了与woo commerce的所有连接,我的产品和所有东西都被正确提取,但当我创建客户时,它会给我一个缺少参数数据的错误

aQuery = new AQuery(context);

HashMap<String, String> stringStringHashMap = new HashMap<>();
String url = WooCommerceAuthentication.getUrl("POST&", "customers", stringStringHashMap);

AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>() {

    @Override
    public void callback(String url, JSONObject jsonObject, AjaxStatus status) {
        System.out.println(jsonObject);
    }
};

String data = "{\n" +
        "\t\"customer\": {\n" +
        "\t\t\"email\": \"myddemaideelo@gmail.com\"}}";
JSONObject jsonObject = null;
try {
    jsonObject = new JSONObject(data);
} catch (JSONException e) {
    e.printStackTrace();
}

cb.header("Accept", "application/json");
cb.header("Content-Type", "application/json");
cb.header("User-Agent", "WooCommerce API Client-PHP/2.0.1");

Map<String, Object> params = new HashMap<String, Object>();
params.put("method", "POST");
params.put("data", "chandan24892@gmail.com");

cb.params(params);

aQuery.ajax(url, JSONObject.class, cb);
aQuery=新的aQuery(上下文);
HashMap StringHashMap=新HashMap();
stringurl=woocmerceauthentication.getUrl(“POST&”,“customers”,stringhashmap);
AjaxCallback cb=新的AjaxCallback(){
@凌驾
公共无效回调(字符串url、JSONObject、JSONObject、AjaxStatus状态){
System.out.println(jsonObject);
}
};
字符串数据=“{\n”+
“\t\“客户\:{\n”+
“\t\t\”电子邮件\“:\”myddemaideelo@gmail.com\"}}";
JSONObject JSONObject=null;
试一试{
jsonObject=新的jsonObject(数据);
}捕获(JSONException e){
e、 printStackTrace();
}
cb.标题(“接受”、“应用程序/json”);
cb.header(“内容类型”、“应用程序/json”);
cb.header(“用户代理”,“WooCommerceAPI客户端PHP/2.0.1”);
Map params=新的HashMap();
参数put(“方法”、“POST”);
参数put(“数据”chandan24892@gmail.com");
cb.params(params);
ajax(url,JSONObject.class,cb);

您提交的客户信息不完整。根据文档,客户字段应为

  "customer": {
    "email": "john.doe@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "username": "john.doe",
    "billing_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US",
      "email": "john.doe@example.com",
      "phone": "(555) 555-5555"
    },
    "shipping_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US"
    }
  }