Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140705

Get an JSON invalid error trying to create a sharepoint document library with javascipt

$
0
0

This is a part of my code, the problem is when I try to use an special character like an spanish accent in the title property. It work fine with normal characters.

 

    const jsonData = JSON.stringify({
                '__metadata': { 
                    'type': 'SP.List' 
                }, 
                'OnQuickLaunch': true,
                'BaseTemplate': 101,
                'Title': name
             });


    const options = {
                hostname: self.host,
                port: 443,
                path: baseUrl + '/_api/web/lists?&$expand=DefaultViewUrl',
                method: 'POST',
                headers: {
                    "Accept": "application/json;odata=verbose",
                    "Content-Type": "application/json;odata=verbose; charset=utf-8",
                    "accept-language": "es-ES,es;q=0.9",
                    "X-RequestDigest": self.digest,
                    'Content-Length': jsonData.length,
                    'Cookie': self.AuthCookie1 +"; " + self.AuthCookie2
                }
            }

When trying to call the https post request The response is


{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"es-ES","value":"JSON no válido. Se encontr\u00f3 un fin de entrada inesperado en el contenido JSON. No se cerraron todos los ámbitos de objeto y de matriz."}}}

I don´t know how to create a sharepoint document library with accent in the title. Debugging the netkork call, in chrome inspector, of the same process directly from the sharepoint create library form, i don´t see differences of headers or body call.


Viewing all articles
Browse latest Browse all 140705

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>