Bukimedia / PrestaSharp

CSharp .Net client library for the PrestaShop API via web service
GNU General Public License v3.0
154 stars 152 forks source link

Object reference not set to an instance of an object when doing an Update #389

Closed Jerir closed 4 years ago

Jerir commented 4 years ago

Hi, I've just downloaded the latest version of Prestasharp and I'm testing it with Prestashop 1.7.6.2.

I'm using VS Pro 2019 with a target .Net framework of 4.5.2

I've added a Windows Forms project to the downloaded VS solution, with a reference to the Bukimedia.Prestasharp library (v1.0.5.1).

The Windows Forms project has some basic code to test the Get, Add, Update and Delete functions - I've tried with manufacturers and suppliers.

The Get, Add and Delete functions work fine, but when I try to do an Update I get the following error (however, the update is successfully made in the Prestashop database).

"System.NullReferenceException. Object reference not set to an instance of an object."

The code for the Update is simply as follows.

ManufacturerFactory mf = new ManufacturerFactory(BaseUrl, Account, Password); manufacturer m = mf.Get(1); m.name = "test"; mf.Update(m);

I've tracked the error down to the RestSharpFactory.Execute function. After this runs for an Update, the Deserialize function is called with the RootElement set to "prestashop" and the content set as follows.

...

This results in the function's "root" variable being set to null which then causes an error in the Map function.

I notice that when Delete calls the RestSharpFactory.Execute function it doesn't then get sent to the Deserialize function.

Does anyone have any idea of why this would be happening?

mowcixo commented 4 years ago

Hello @Jerir, try with 1.1.0 version. Some fixes related to your error were fixed in that version.

Jerir commented 4 years ago

Hi @mowcixo . I've downloaded the latest version from https://github.com/Bukimedia/PrestaSharp but this appears to be the same as the version I downloaded on 23rd Jan 20. I've compared all files in the Prestasharp folder and they are identical. Is there another place for me to download version 1.1.0?

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.