1. #1
    Sencha User
    Join Date
    Jun 2014
    Posts
    14
    Vote Rating
    0
    Bramaram Naik Nenavath is on a distinguished road

      0  

    Default Unanswered: ExtJS: POST http://localhost:8080/auth/user/ 400 Bad Request

    Unanswered: ExtJS: POST http://localhost:8080/auth/user/ 400 Bad Request


    Hi,

    I am using proxy type as "ajax" or "jsonp".Both cases am getting the below exception in browser console
    I am sending a "POST" request through "MyStore" as shown below and using "MyController" for appending params(Username and Password). Now we i send POST request now am getting below exception.

    POST http://localhost:8080/..../api/v3.0/es/user/authenticate?_dc=1404206954377 400 (Bad Request)

    As per my observation,
    the request should be in this format observed in browser console : {"username":"xyz","password":"abc"}
    By using below prozy it sending request in this format in browser console which may be wrong username=asas&password=asas
    Which is causing 400 bad request.

    Kindly help me to resolve this issue.
    Thanks in advance,
    Nenavath


    MyStore:
    ----------

    Ext.define('MyApp.store.loginstore', {
    extend: 'Ext.data.Store',
    requires : 'MyApp.model.loginmodel',
    model: 'MyApp.model.loginmodel',


    autoLoad : false,

    proxy: {
    type: 'jsonp',
    actionMethods : {
    read : 'POST'
    },

    url: 'http://localhost:8080/MyWebservice/api/v3.0/es/user/authenticate',
    //noCache: true,
    startParam: '',
    pageParam: '',
    limitParam: '',
    headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
    },
    reader: {
    type: 'json'
    },
    writer: {
    type : 'json',
    encode: true
    }

    }
    });


    My Controller:
    -----------------



    Ext.define('MyApp.controller.logincheckcontroller', {

    extend: 'Ext.app.Controller',
    requires: [
    'MyApp.view.main.Main',
    'Ext.container.Viewport',
    'Ext.toolbar.Spacer',
    'Ext.form.field.ComboBox'
    ],
    stores: [
    'loginstore'
    ],
    init: function(){

    var me = this;
    me.control({
    'button[name="login"]': {
    click: function(){
    var UserID = Ext.getCmp('userid').getValue();
    var Password = Ext.getCmp('password').getValue();
    var loginstore = Ext.getStore('loginstore');
    loginstore.load({
    params: {
    username:UserID,
    password:Password
    },
    callback: function(records, operation, success) {
    if(success) {
    Ext.Msg.alert("loginsuccess","Login Successfull");
    }else {
    Ext.Msg.alert("loginfailure","Invalid Username/Password");
    }
    }
    });
    }
    }

    });
    },

    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    JsonP is going to always be GET, JsonP loads by creating a <script> so it will always be GET, there is no way to change that.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2014
    Posts
    14
    Vote Rating
    0
    Bramaram Naik Nenavath is on a distinguished road

      0  

    Default


    Thanks for the response,


    I want to send both "GET and POST" requests to "Rest full Service" (to Remote system not local system) using "Ajax" through my Store (using proxy type:'ajax')


    .Now I request you to suggest the proxy type to be used in my store which supports for both "GET and POST" as well as "Remote System"(not local system).


    Thanks

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You can use Ajax or Rest proxy, only thing is the server must support CORS in order for that to work.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1