I'm invoking the woocommerce API to import all the orders from my online store to my personal environment. This process will create new or update existing orders. 

Since the woocommerce api only returns 10 records at a time i need to send the page=n parameter in the request parameters. What i'm doing is a cycle that increases the pagenr until the request has no results.

On the first round, all works fine but on the second one I get an error:

Failed to parse response of the method 'GetOrders' of the 'xxxxx' REST API:
Parsing '[1].meta_data[5].value': Unexpected character encountered while parsing value: [. Path '[1].meta_data[5].value', line 1, position 4310.
Parsing '[1].meta_data[5]': JsonToken EndArray is not valid for closing JsonType Object. Path '[1].meta_data[5]', line 1, position 4311.
Parsing '[1].meta_data[5]': Unexpected character encountered while parsing value: }. Path '[1].meta_data[5]', line 1, position 4311.

Anyone has any ideia why this appens?




Hello Miguel,

What is the full JSON you are receiving the second time?



P.S. I would say that when you consumed the rest method, the answer was not a full answer, so you are missing attributes, or most probably the answer has an attribute that sometimes comes as a single value, and sometimes comes as an array.

If it is the second situation, you need to change the attribute in the structure used to receive the data to be a list and pre-process the answer of the method to change the attribute to be an array if it comes as a single value.



Thanks for your answer Eduardo.

Following your second ideia I found that the JSON has a field that in one situation comes defined as an array but on the rest of the situations is a string... I only dont't know how to handle this.. also I don't need that structure.


EDIT: I found a solution... since I don't need that structure I removed it from the output ;-) It's working now.

Thanks for your help.

Glad to be of help, :)