来自android volley http post请求的Hyperledger作曲家“意外的响应代码500”

问题描述 投票:0回答:2

我想通过volley http客户端库从android发布数据到hyperledger composer。下面是代码。

String url="http://50.23.0.202:31090/api/Doctor";
private void postUsingJson() throws JSONException {
    RequestQueue requstQueue = Volley.newRequestQueue(this); // this = context
    JSONObject jsonObject=new JSONObject();

    jsonObject.put("$class", "org.acme.Doctor");
    jsonObject.put("doctorID", "300");
    jsonObject.put("doctorName", "Zubair ");
    jsonObject.put("contact", "05654");
    jsonObject.put("description", "Cardiologist");
    jsonObject.put("schedule", "resource:org.acme.Schedule#2");

    System.out.println("json "+jsonObject);
    JsonObjectRequest jsonobj = new JsonObjectRequest(Request.Method.POST, url,jsonObject,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    System.out.println("response "+response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    System.out.println("hi "+error.getMessage());
                }
            }
    );
    jsonobj.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 48,
            0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    requstQueue.add(jsonobj);
}

After running this code i get this error

当我复制相同的json(如上图所示)并通过composer rest server发布时,它工作正常。

android http-post android-volley hyperledger-fabric hyperledger-composer
2个回答
0
投票

我希望我不会太迟。看起来您的商业网络已经有一名医生,其医生ID为300,因此您不能添加具有相同doctorID的其他用户,因为doctorID必须是唯一的。尝试将医生的ID更改为网络上尚未包含的任何其他号码。


0
投票

我不确定你是否解决了这个问题。但有时,使用Wireshark等工具验证实际的http数据包非常有用。您可以比较卷曲和应用程序之间的数据包

© www.soinside.com 2019 - 2024. All rights reserved.