nla-brandonjames / BC4Net

A .NET Standard port of rworst's BigCommerce4Net
0 stars 0 forks source link

PostDataAsync and PutDataAsync double-serialize to JSON #1

Open weirdian2k3 opened 7 years ago

weirdian2k3 commented 7 years ago

In PutDataAsync and PostDataAsync, the data that is passed to them is serialized to JSON.

But all callers to these methods are already serializing the data and passing a JSON string directly to these methods, so the methods serialize the string leading to requests like this

"{\r\n \"id\": 0,\r\n \"first_name\": \"John\",\r\n \"last_name\": \"Smith\",\r\n \"email\": \"sample@domain.com\",\r\n \"phone\": \"\",\r\n \"date_created\": \"\",\r\n \"date_modified\": \"\",\r\n \"store_credit\": 0.0,\r\n \"customer_group_id\": 0\r\n}"

instead of

{ "id": 0, "first_name": "John", "last_name": "Smith", "email": "sample@domain.com", "phone": "", "date_created": "", "date_modified": "", "store_credit": 0.0, "customer_group_id": 0 }

Removing the calls to JsonConvert.SerializeObject should fix both methods.

nla-brandonjames commented 7 years ago

Sorry for just now getting to this issue. I've been busy with other projects and getting an education on the new systems my company is moving to in the next month. I've just finished a client for another web service and am moving on to the next one. I've got a few new projects queued up already so we can integrate all our data. Also, .NET Standard 2.0 came out so all my new projects will be using that version.

If you can make the change you requested and send me a pull request I would gladly accept it, but since BigCommerce API v3 is next on my scope, after Zoho Books API which I'll be starting today, I'll likely stop maintaining this library. I know this is such an easy fix, but it looks like my business is going to drop this API.