Problem with Rest API v2 – Extra text added before response
-
I just encountered a strange problem and I spent couple of hours on debugging the issue.
I’m developing an Android app for my website https://www.geekdashbaord.com/ using Rest API v2 and I noticed extra text is added at the beginning of response only for few endpoints.
More details
I’m fetching 5 recent posts at once and loading next 5 after scrolling. But my app is crashing at offest 70 yesterday.and today my app is crashing for 1st and 2nd posts and working fine from the third post and again crashing at 72th post.
I debugged the response from the postman and noticed a strange issue.
If you test this end post in postman or browser https://www.geekdashboard.com/wp-json/wp/v2/posts?per_page=25&offset=1
you can see these extra lines before the actual response
<script type="text/javascript">hide_compare_list = true;var ajaxurl = "https://www.geekdashboard.com/wp-admin/admin-ajax.php",comp_link = "https://www.geekdashboard.com/compare/",comp_cn = "aps_comp_www_geekdashboard_com",msg_suc = "<strong>Success:</strong> You have added <strong>%title%</strong> to your <a href=\"%link%\">comparison list</a>",msg_ful = "<strong>Sorry:</strong> Your <a href=\"%link%\">Comparison list</a> is full, you can compare upto 3 products at a time.",msg_dup = "<strong>%title%:</strong> is already found in your <a href=\"%link%\">comparison list</a>",msg_rem = "<strong>%title%:</strong> is successfully removed from your <a href=\"%link%\">comparison list</a>";</script>
and If you test these API calls
https://www.geekdashboard.com/wp-json/wp/v2/posts?per_page=25&offset=25
https://www.geekdashboard.com/wp-json/wp/v2/posts?per_page=25&offset=28
https://www.geekdashboard.com/wp-json/wp/v2/posts?per_page=25&offset=28no errors are found in response. It is very clear for me, that extra code belongs to Arena Products Store – WordPress Plugin. I disabled the plugin and everything works fine.
and also it is clear that I’m getting this error if few specific post id is present in the response.
So, do you think it is problem with the plugin? If it is problem with the plugin, then why only few end point are failing?
- The topic ‘Problem with Rest API v2 – Extra text added before response’ is closed to new replies.