Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddObject incorrect serialization for List #1063

Closed
ericnewton76 opened this issue Jan 1, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@ericnewton76
Copy link

commented Jan 1, 2018

Sample code:

	public class Person { public string Name { get; set; } }

	class Program
	{
		static void Main(string[] args)
		{
			var list = new List<Person>();
			list.Add(new Person { Name = "Joe" });
			list.Add(new Person { Name = "Mary" });

			var request = new RestRequest("url");
			request.AddObject(list);

			new RestClient("http://localhost:1234").Execute(request);
		}
	}

Expected Behavior

Accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml
User-Agent: RestSharp/106.2.0.0
Content-Type: application/json
Host: api.godaddy.com
Content-Length: xxx
Accept-Encoding: gzip, deflate

[{"name":"Joe"},{"name":"Mary"}]

<!-- If this issue is a feature request remove text below -->

Actual Behavior

serialized:
Accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml
Authorization: XXXXXXXXXXXXXXXXXXXXXX
User-Agent: RestSharp/106.2.0.0
Content-Type: application/x-www-form-urlencoded
Host: api.godaddy.com
Content-Length: 141
Accept-Encoding: gzip, deflate

Length=1&LongLength=1&Rank=1&SyncRoot=ConsoleApp1.Person%5B%5D&IsReadOnly=False&IsFixedSize=True&IsSynchronized=False

Steps to Reproduce the Problem

  1. paste code
  2. run
  3. observe via Fiddler

Specifications

  • Version:
  • Platform:
  • Subsystem:

StackTrace


@alexeyzimarev alexeyzimarev changed the title AddObject incorrect serialization for Array AddObject incorrect serialization for List Jan 1, 2018

@alexeyzimarev

This comment has been minimized.

Copy link
Member

commented Jan 1, 2018

The code is identical to #1062. Please do some clean up.

@alexeyzimarev

This comment has been minimized.

Copy link
Member

commented Jan 1, 2018

Ok, here we go:

AddObject

Calls AddParameter() for all public, readable properties specified in the includedProperties list

What you want is AddJsonBody

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.