Magento 1.9 Rest API POST创建新用户

时间:2017-04-24 09:41:31

标签: magento-1.9

我正在使用自定义Magento Rest API来创建新用户,我的邮递员请求数据是:

网址:http://megashopping.am/api/rest/register/store/1

content-type:application / json

键:名字

但是我遇到了这个错误

{
  "messages": {
    "error": [
      {
        "code": 400,
        "message": "Decoding error."
      }
    ]
  }
} 

我的XML文件是

<extendrestapiregister translate="title" module="api2">
                <group>extendrestapi</group>
                <model>extendrestapi/api2_register</model>
                <title>Register</title>
                <sort_order>10</sort_order>
                <privileges>
                    <guest>
                       <retrieve>1</retrieve>
                       <create>1</create>
                    </guest>
                </privileges>
                <attributes   >
                    <firstname>First Name</firstname>                    
                </attributes>
                <routes>
                    <route_entity>
                        <route>/register/:id/store/:store_id</route>
                        <action_type>entity</action_type>
                    </route_entity>
                    <route_collection>
                        <route>/register/store/:store_id</route>
                        <action_type>collection</action_type>
                    </route_collection>                    
                </routes>
                <versions>1</versions>
            </extendrestapiregister>

我的班级

<?php

/**
 * Override for Magento's Catalog REST API
 */
class ITology_RestApi_Model_Api2_Register_Rest_Guest_V1 extends Mage_Api2_Model_Resource {


    /**
     * Create a customer
     * @return array
     */


     public function _create(array $data) {

        return $firstName = $data['firstname'];


    }


}

0 个答案:

没有答案