Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:40:19+00:00 2026-06-14T22:40:19+00:00

I have the follow bit of Javascript: $.ajax({ url: /Web/WebServices/Operation.svc/SetScope, type: POST, contentType: application/json;

  • 0

I have the follow bit of Javascript:

 $.ajax({
    url: "/Web/WebServices/Operation.svc/SetScope",
    type: "POST",
    contentType: "application/json; charset=utf-8",
    beforeSend: function () {
    },
    dataType: "json",
    cache: false,
    data: JSON.stringify({
        Id: Id,
        RIds: RIds,
        rScope: rScope 
    }),
    success: function (data) { onSuccess(data); },
    error: function (data) { onError(data); }
    });

If you look at the data bit —

  • Id is an int
  • RIds is array of ints
  • rScope is an array of objects each containing an int and a string

The result of

data: JSON.stringify({
            Id: Id,
            RIds: RIds,
            rScope: rScope 
        })

is

‘{“Id”:1,”rIds”:[1,2,3,4],”rScope”:[{“id”:3,”type”:”barney”},{“id”:2,”type”:”ted”}]}’

Passing it into $.parseJSON returns the expected object.

The problem is that it returns 400 Bad Request.

The signature waiting for the call is in WCF hosted in IIS

public OperationResult SetScope(int rId, string rIds, string rScope)

If I remove rScope from the code, everything is fine, but it seems to be having trouble with an array populated with objects as opposed to just primitives.

What am I missing here?

I found similar questions but none that really explained my scenario.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:40:20+00:00Added an answer on June 14, 2026 at 10:40 pm

    If I’m not mistaken the result of your parsing implies that rScope is an object array with each object having an id and a type property and not just a simply string.

    "rScope":[{"id":3,"type":"barney"},{"id":2,"nodetype":"ted"}]
    

    If you have a class similar to this:

    public class ScopeClass{
        public int Id {get; set;}
        public string Type {get; set;}
    }
    

    And use it in your method like this:

    public OperationResult SetScope(int rId, string rIds, IList<ScopeClass> rScope)
    

    Edit

    Actually, I just noticed you also have the second object named nodetype instead of type.

    If you use the above aproach you need to make sure in your data you pass up the nodetype is also named type, otherwise you can’t match the values.

    Also, using the property name Type might not be a good idea due to C#’s type of Type. If you have any influence you can update Type to something more meaningfull as in GroupType or what ever it represents and then name it the same in the data passed up. The model binder should then simply magic-match it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this follow code in my javascript. I call this function when the
As a bit of a follow up to Javascript form won't submit (to view
I am trying to create, essentially, a 'kiosk' I have an web application that
I want to experiment a bit with web applications (and especially mobile web application).
I am having a bit of difficulty working something out. I have the follow
Is there any way to follow a URL in JavaScript without setting the document.location.href
hello fellow java developers. I'm having a bit of an issue here. I have
i have follow taxomony has been set up: accommodation -backpacker -guest -holiday and i
I have the follow query: SELECT pro.* FROM tb_AutProposta pro, tb_AutParcelamento par WHERE pro.id
I have a follow-up question to this one . I created a new form,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.