HttpService WriteJson Error

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Interested
Rating: 10
Joined: Sep 30, 2020
Company: Nortek Bilişim

Hello, I try to write HttpService and take an error like in Error picture.I have added my code in Code picture.

English of the error is:
Error occurred during context method call process

What is the solution of this error?

I have emphasize that I am working on 1C:Drive.

Download Code.PNG (26.15 KB)
Edited: Mesut Kahraman - Feb 25, 2021 01:59 PM
 
#2
People who like this:0Yes/0No
Administrator
Rating: 13
Joined: Oct 3, 2019
Company:

Hi Mesut,

at first glance, there are no errors in your code...

Please check with the debugger: does the GetArrayProduct() procedure return an array or not? In general, does  "str" structure contain any data or not?

 
#3
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Nov 4, 2020
Company:

Probably you forget set New JsonWriterSettings. Can you try this ?

Code
JSONWriter = New JSONWriter;
JSONWriterSettings = New JSONWriterSettings(, Chars.Tab);
JSONWriter.SetString(JSONWriterSettings);
WriteJSON(JSONWriter, str);
Result = JSONWriter.Close();

 
#4
People who like this:0Yes/0No
Administrator
Rating: 13
Joined: Oct 3, 2019
Company:

This is hardly the reason...

Here is a piece of working code:

Code
If MethodName = "pricelist" Then 
      
   structureResult = New Structure;
   structureResult.Insert("products",    GetArrayProducts());
   structureResult.Insert("prices",    GetArrayPrices());
   structureResult.Insert("barcodes",    GetArrayBarCodes());
      
   JSONWriter = New JSONWriter;
      
   JSONWriter.SetString();
      
   WriteJSON(JSONWriter, structureResult);
   
   result = JSONWriter.Close();
   
Else 
      
   Response.StatusCode = 405;
   result = "Not found Method: " + MethodName;
      
EndIf;

 
#5
People who like this:0Yes/0No
Administrator
Rating: 13
Joined: Oct 3, 2019
Company:

In any case, we need to understand what the procedure GetArrayProduct() returns :-)

 
#6
People who like this:0Yes/0No
Interested
Rating: 10
Joined: Sep 30, 2020
Company: Nortek Bilişim

I have tried you said but not works.Here is GetArrayProduct().Is there any errors in the function?

 
Subscribe
Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.