1
ApiGility을 처음 사용하고 API 호출을 통해 장바구니를 경로에 추가하여 업데이트하려고합니다. Zend Framework 2와 API를 연결 한 코드를 사용하고 있습니다.ApiGility - PUT을 사용하여 유효성 검사 오류 가져 오기
내가 현재 직면하고있는 문제는 무엇을 시도하든 인증 오류없이 API에 정보를 넣을 수 없다는 것입니다.
내 module.config :
Updatecart 설정 :
'Api\\V1\\Rest\\Updatecart\\Controller' => array(
'listener' => 'Api\\V1\\Rest\\Updatecart\\UpdatecartResource',
'route_name' => 'api.rest.updatecart',
'route_identifier_name' => 'updatecart_id',
'collection_name' => 'updatecart',
'entity_http_methods' => array(
0 => 'GET',
1 => 'PATCH',
2 => 'PUT',
3 => 'DELETE',
),
'collection_http_methods' => array(
0 => 'GET',
1 => 'POST',
2 => 'PUT',
3 => 'PATCH',
4 => 'DELETE',
),
'collection_query_whitelist' => array(
0 => 'prod_id',
1 => 'quantity',
2 => 'quantity_accumulation',
3 => 'tax',
),
'page_size' => 25,
'page_size_param' => null,
'entity_class' => 'Api\\V1\\Rest\\Updatecart\\UpdatecartEntity',
'collection_class' => 'Api\\V1\\Rest\\Updatecart\\UpdatecartCollection',
'service_name' => 'updatecart',
),
관련 필터 설정 :
'Api\\V1\\Rest\\Updatecart\\Validator' => array(
0 => array(
'name' => 'prod_id',
'required' => true,
'filters' => array(
0 => array(
'name' => 'Zend\\Filter\\Int',
'options' => array(),
),
),
'validators' => array(),
'description' => 'The id of the product in the cart to be updated',
'error_message' => 'Missing product id',
'allow_empty' => false,
'continue_if_empty' => false,
),
1 => array(
'name' => 'quantity',
'required' => true,
'filters' => array(),
'validators' => array(),
'description' => 'quantity of product',
'error_message' => 'You must include a quantity',
'allow_empty' => false,
'continue_if_empty' => false,
),
2 => array(
'name' => 'tax',
'required' => true,
'filters' => array(),
'validators' => array(),
'description' => 'Add the VAT, GST, Sales Tax that will be applicable to this item. Use 0.00 for no value.',
'error_message' => 'Please add a tax value, 0.00 for no value.',
'allow_empty' => false,
'continue_if_empty' => false,
),
3 => array(
'name' => 'quantity_accumulation',
'required' => true,
'filters' => array(
0 => array(
'name' => 'Zend\\Filter\\Boolean',
'options' => array(),
),
),
'validators' => array(),
'description' => 'Either accumulate the entered quantity to the current basket quantity or set as the entered quantity.',
'allow_empty' => false,
'continue_if_empty' => false,
'error_message' => 'Quantity accumulation field error.',
),
),
PUT 메소드 호출 :
https://cloud.mysite.dev:8890/api/updatecart/1?prod_id=1&quantity=1&update_type=1&tax=0.00
을내가 실패하기 계속 검증 오류 :
당신은 JSON 형식으로 HTTP 본문 (페이로드)와 같은 데이터를 제공해야{
"validation_messages": {
"prod_id": [
"Missing product id"
],
"quantity": [
"You must include a quantity"
],
"tax": [
"Please add a tax value, 0.00 for no value."
],
"quantity_accumulation": [
"Quantity accumulation field error."
]
},
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "Unprocessable Entity",
"status": 422,
"detail": "Failed Validation"
}
확인 감사, 크롬 우체부를 통해이 작업을 수행하는 방법에 어떤 생각을? 몇 가지 다른 방법을 시도했지만 올바른 방법을 모릅니다. tx – HappyCoder
물론, 나도 그것을 사용합니다. 요청 URI를 입력하고 드롭 다운에서 'PUT'을 선택하십시오. 머리글 단추를 클릭하여 머리글을 추가하십시오. '원시'버튼을 선택하여 페이로드를 삽입 할 수 있습니다. –