FubarDevelopment / restsharp.portable

Some kind of a RestSharp port to PCL
BSD 2-Clause "Simplified" License
96 stars 33 forks source link

Post request - array parameter not working properly #71

Closed jeevanrd closed 8 years ago

jeevanrd commented 8 years ago

Here is the code;

var client = new RestClient ("http://localhost:3000"); var request = new RestRequest ("products", Method.POST); request.AddParameter ("countryCode", "US", ParameterType.GetOrPost); request.AddParameter ("storeId", "1001", ParameterType.GetOrPost); request.AddParameter ("storeId", "1002", ParameterType.GetOrPost); var response = client.Execute(request).Result;

At the server end, only one storeId (the last one, 1002) is coming.

The same request via curl works perfectly.

curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Accept: application/json" -d "countryCode=US&storeId=1001&storeId=1002" "http://localhost:3000/products"

What I am my doing wrong here? Is this that the limitation?

Can some one pls advise.

Thanks

fubar-coder commented 8 years ago

This is a limitation. You may want to try storeId[0]=1001&storeId[1]=1002 instead. This should work too.

fubar-coder commented 8 years ago

I'll try to lift this limitation for 4.0, but it's not there yet.

jeevanrd commented 8 years ago

You mean to say, If I pass like below the request should go through?

request.AddParameter ("storeId[0]", "1001", ParameterType.GetOrPost); request.AddParameter ("storeId[1]", "1002", ParameterType.GetOrPost);

fubar-coder commented 8 years ago

Yes, it might work (I've already seen this :wink:)

jeevanrd commented 8 years ago

Sry, It didn't work out. Any other ways you can suggest to achieve this.?

fubar-coder commented 8 years ago

OK, I'll try to fix this and get a new pre-release out tomorrow

jeevanrd commented 8 years ago

Thanks @fubar-coder. Please leave a message here once you publish.

fubar-coder commented 8 years ago

It's available as beta on the RestSharp.Portable MyGet Gallery. The NuGet v3 feed is: https://www.myget.org/F/restsharp-portable/api/v3/index.json

Be aware, that you have to use NuGet 3.5.0 beta to be able to consume this package. Please reopen this issue, when this issue is not resolved.

jeevanrd commented 8 years ago

Getting error saying

'4.0.0-beta-01.10' is not a valid version string

fubar-coder commented 8 years ago

I'll fix this ASAP.

fubar-coder commented 8 years ago

What client do you use to install the NuGet packages? Where exactly does this happen? It works fine here when using Visual Studio 2015, both with .NET Core RC2 and .NET 4.5 console applications.

fubar-coder commented 8 years ago

I pushed pakages with a new version number: 4.0.0-beta1-012. I hope that your client can now handle this version number... Maybe your dotnet tool is too old?

jeevanrd commented 8 years ago

I was using nuget client to install nuget packages in xamarin studio 5.10.2.

fubar-coder commented 8 years ago

Does it work now? Maybe you have to use nuget 3.5.0 beta?

jeevanrd commented 8 years ago

@fubar-coder. I was using xamaraion studo framework on MAC osx for this. I tried using nuget client 3.5.0 beta only to install packages in NET 4.5 console applications only. But still unable to add the package. It says " Adding FubarCoder.RestSharp.Portable.Core... Attempting to resolve dependency 'Newtonsoft.Json (≥ 8.0.4-beta1)'. Downloading FubarCoder.RestSharp.Portable.Core 4.0.0-beta1-012... 'FubarCoder.RestSharp.Portable.Core' already has a dependency defined for 'NETStandard.Library'. "

But My target is to create a PCL library using restsharp with targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10".

Thanks

fubar-coder commented 8 years ago

That's it. Xamarin Studio doesn't support the new nuget packages. I'll do some investigation, and answer you again about possible solutions.

fubar-coder commented 8 years ago

I made a back-port of the 4.0 changes to 3.3.0 (on nuget.org). Please try this version. You should be able to install this in Xamarin.Studio. Sorry for the hassle and thank you for your patience.

jeevanrd commented 8 years ago

Sorry for giving you trouble once again. May be it's some limitations in xamarin studio. Still unable to add package. It's says "Adding FubarCoder.RestSharp.Portable... Attempting to resolve dependency 'FubarCoder.RestSharp.Portable.HttpClient (≥ 3.3.0)'. '4.0.0-beta-01.10' is not a valid version string. Parameter name: version"

fubar-coder commented 8 years ago

The latest version is beta1-012. This should work

fubar-coder commented 8 years ago

I changed the version number to avoid exactly this problem.

jeevanrd commented 8 years ago

@fubar-coder Thanks for your patience. This also didn't work out. Still getting error "Adding FubarCoder.RestSharp.Portable.Core... Attempting to resolve dependency 'Newtonsoft.Json (≥ 8.0.4-beta1)'. Downloading FubarCoder.RestSharp.Portable.Core 4.0.0-beta1-012... 'FubarCoder.RestSharp.Portable.Core' already has a dependency defined for 'NETStandard.Library'."

If possible pls try to create a sample PCL library in xamarin studio and test adding this package to that

Thanks

fubar-coder commented 8 years ago

Too long awake. Please use 3.3.0 from nuget.org. I made a backport.

jeevanrd commented 8 years ago

Thank you very much for your patience. Finally issue resolved 👍 👍

fubar-coder commented 8 years ago

Good :grinning: