I'm having an issue with certain JSON responses every time I make a GET call to MercadoLibre API
. So far what I have found is that when response is too large, I get a null value, but i was able to solve it. This is my code:
SET TEXTSIZE 2147483647
DECLARE @url VARCHAR(8000) = 'https://api.mercadolibre.com/products/MLA18648076'
DECLARE @token as int;
DECLARE @respuesta as VARCHAR(8000);
DECLARE @ret INT;
DECLARE @respuesTabla table(respuestaTxt nvarchar(max))
EXEC sp_OACreate 'MSXML2.XMLHTTP', @token OUT;
IF @ret <> 0 RAISERROR('Unable to open HTTP connection.', 10, 1);
EXEC @ret = sp_OAMethod @token, 'open', NULL, 'GET', @url, 'false';
EXEC @ret = sp_OAMethod @token, 'send'
insert into @respuesTabla (respuestaTxt)
EXEC @ret = sp_OAMethod @token, 'responseText'
select @respuesta = respuestaTxt from @respuesTabla
select @respuesta
EXEC sp_OADestroy @token
Now, response looks ok but if i try to open with OPENJSON i get the error that Json format isnt ok.
BUT,if i download the response to txt and use OPENROWSET i actually can read the json file. So...what's the problem?