Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > HttpService WriteJson Error

Forum

Search UsersRules
HttpService WriteJson Error
#1
Interested
Points:: 0
Joined:: Sep 30, 2020

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.

Profile
#2
Administrator
Points:: 0
Joined:: Oct 3, 2019

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?

Profile
#3
Just came
Points:: 0
Joined:: Nov 4, 2020

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();

Profile
#4
Administrator
Points:: 0
Joined:: Oct 3, 2019

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;

Profile
#5
Administrator
Points:: 0
Joined:: Oct 3, 2019

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

Profile
#6
Interested
Points:: 0
Joined:: Sep 30, 2020

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

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.