如何修复“未找到翻新注释。(参数#2)”?

时间:2019-08-22 12:27:00

标签: android retrofit2

我想发送一个HTTP发布请求,到目前为止一切都很好(我在此应用程序中发送了10个以上的请求),但是现在出现了问题。

我收到此错误:

start()

这是接口代码:

is_uploaded_file

这是我的MainActivity代码:

 <?php
 ...
 if (is_post_request()) {

    // Do your normal `category` processing
    $args = $_POST['category'];
    $category->merge_attributes($args);

    // Only process the file if the user uploaded it. 
    if (is_uploaded_file($_FILES['cat_image']['tmp_name'])) {
        $category->set_file($_FILES['cat_image']);
        $result = $category->save_photo();
    }

    ...
}

此行有错误:

 <?php
 ...
 if (is_post_request()) {

    // Do your normal `category` processing
    $args = $_POST['category'];
    $category->merge_attributes($args);

    // Only process the file if the user uploaded it. 
    if (is_uploaded_file($_FILES['cat_image']['tmp_name'])) {

        // Check if image already exists. 
        // I do not know anything about your tables so I am just making one up here. 
        // Please don't ask me to write this for you. 
        // This is just pseudo code.
        $query = 'SELECT 1 FROM table WHERE id = ? AND image_url IS NOT NULL';

        if ($query->result == 1) {
          // The row already contains a value - do something. Or not...
        }

        $category->set_file($_FILES['cat_image']);
        $result = $category->save_photo();
    }

    ...
}

2 个答案:

答案 0 :(得分:2)

您尚未注释第二个参数。...可以是@ Body,@ Query等。...添加注释

答案 1 :(得分:0)

将界面方法更改为此

@FormUrlEncoded
@POST("index.php/web/request")
    Call<MyResponse> getMy(@Header("authorization") String token);

@FormUrlEncoded
    @POST("index.php/web/request")
        Call<MyResponse> getMy(@Header("authorization") String token, MyRequest myRequest);