2

I wrote a function in angularjs, that send the array to API. (I'm using asp.net).

function getDimensionTagsByIds(tagIds) {

        return msApi.resolve('app.entities.dimensions-tags-search@query', {tagsId: tagIds});
    }

this is the function in the API that receives this request:

[HttpGet]
    [Route("tags-search")]
    [EnableQuery]
    public async Task<IQueryable<SimpleDimensionViewModel>> SearchTags([FromUri] List<int> tagIds)
    {
        return (await _mediator.SendAsync(new ProjectedQuery<DimensionTag, SimpleDimensionViewModel>())).Where(dt => tagIds.Contains((int)dt.TagId));
    }

when I debug my code I see that the tagIds get all the time empty List. I tried to change the parameter to array, but its still doesn't work. what I'm doing wrong?

thanks for the help!

5
  • 1
    You are sending object with "tagsId" property. Plural tagS and singular Id. And your parameter is singular - tag and plural IdS Commented Oct 4, 2018 at 6:25
  • no, tagsid is an array of string, I tried to change the type of the list to be list<string> but it still, refuse to work Commented Oct 4, 2018 at 6:28
  • 1
    Sorry, maybe I was not clear - I meant that you have different names there. tagsid vs tagids. If you have different types on top of it - the app should throw the conversion exception. To debug it you could change the list to have strings instead of ints - just for testing Commented Oct 4, 2018 at 6:30
  • 1
    Thanks! now its working! Commented Oct 4, 2018 at 6:33
  • No worries. I`ll post this as answer Commented Oct 4, 2018 at 6:35

1 Answer 1

4

You have a simple typo:

Your angular is sending property tagsId And your backend is waiting for tagIds

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

Comments

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.