0

I have the following code:

$http.post('/api/City?cityId=' + $scope.config.cityId)

This works and sends the expected URL to the server.

Now I would like to add more to the URL to send additional information. Is there a way I can define the details such as cityId in an object and have this sent? Note that I did try:

$http.post('/api/City', {
             params: {
                 cityId: $scope.config.cityId
             }
})

This has the effect of sending a JSON object containing cityId to the server which is not what I want in this case as my server is expecting this:

    [HttpPost]
    [ActionName("City")]
    public HttpResponseMessage City(int cityId, int locId, testId)

1 Answer 1

1

The params object is a property of the third parameter to the $http.post function, not the second.

http://docs.angularjs.org/api/ng/service/$http#post

You can also use the long version

$http({
  method: 'POST',
  url: '/api/City'
  params: {...}
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.