1

I have rest API built in WSO2 ESB. This is my request in service for POST method.

createUser: function(aUser) {
            var myCreateUserRequest =  {
                       "User":    {
                          "UserName": aUser.Username,
                          "UserPassword": aUser.Password,
                          "OrganizationId": aUser.OrgId,
                          "UserStatus": "Active", }}          
            //API Call
            var promise = $http.post(API_URL,myCreateUserRequest,REQUEST_HEADER).then(
            function(aCreateUserResponse) { 
                return [aCreateUserResponse.data.CreateUserResponse.Result.ResponseCode,''];
            });
             return promise; },

NOW similarly I want to pass only 2 parameter to GET a user i.e UserName and Organization id. How can I do that in angular js? What I have implemented so far is:

getUser: function() {
            params =  {"UserName": aUser.Username, "OrganizationId": aUser.OrgId}         
            //API Call
            var promise = $http.get(API_URL,params,REQUEST_HEADER).then(
            function(aGetUserResponse) { 
                return [aGetUserResponse.data.GetUserResponse.Result,''];
            });
             return promise; },

Is this is the correct way to do else how can I do this?

1 Answer 1

1

No, this isn't correct, as POST has a data parameter, GET does not (because there is no body in Get request). Docs

In order to pass those parameters, you need to add them to the URL as querystrings

Sign up to request clarification or add additional context in comments.

5 Comments

What is the exact syntax?
There isn't a syntax for this - a put request just needs the right querystring - mysite/api/method?UserName=abc123&OrganizationId=def456
Link is not working and u means just to send parameter with url ?
Yes. A get request needs the parameters as a part of the URL. (also I fixed the link. )
now i am passing parameters but my sequence is changing that is why I am getting 404.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.