1

So, I added some code in Content Editor Web Part and code is started like this:

<script src="/<MyURL>/_layouts/15/SP.Runtime.js" type="text/javascript"></script>
<script src="/<MyURL>/_layouts/15/SP.js" type="text/javascript"></script>
<script src="/<MyURL>/SiteAssets/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="/<MyURL>/SiteAssets/knockout-3.0.0.js" type="text/javascript"></script>
<script src="/<MyURL>/SiteAssets/Script.js" type="text/javascript"></script>

For all these files I get a similar error for each in Chrome console:

GET http://MyURL/%3CSiteURL%3E/SiteAssets/knockout-3.0.0.js 400 (Bad Request) 

...

I googled but the this error pops up so often for various situations that couldn't find answer for me and SharePoint. Any ideas?

  • Why Content Editor? Use Script Editor. If you remove the Knockout line doest it work? – Nk SP Jul 24 '14 at 7:56
  • I use Content Editor then I use a script editor in it. About an error, I get the same error for each file. – user3529236 Jul 24 '14 at 8:00
  • 1
    Try to add a script editor and remove <MyURL> use this source src="/_layouts/15/script.js" – Nk SP Jul 24 '14 at 8:02
  • Done it. Those errors are gone but now the table that my code was supposed to create with information is gone(previously it showed table but with no info) and I get new error like: Uncaught ReferenceError: /// args is not defined Script.js:61 /// my.vm.RetrieveItemsFail Script.js:61 /// (anonymous function) ScriptResource.axd?d=7bHa5m1dromXowi_eKldYsSiVPVUf6sqCQuHirM_ocGiCS3HymjC2gXwHY0NrucbnjCzbrk7XhxT76…:5 /// SP.ClientRequest.$h_0 SP.Runtime.js:2 /// SP.ClientRequest.$32_0 SP.Runtime.js:2 – user3529236 Jul 24 '14 at 8:14
  • that on is a js error, to begin try to import just simple js file and see that they re working fine. – Nk SP Jul 24 '14 at 8:16
1

This answer is community wiki. Feel free to improve.

The URI path component cannot contain angle brackets (< >), that are encoded as %3C and %3E in your Bad Request. Other offending characters in URL components may include but aren't limited to commas ,, question marks ?, asterisks *, colons :, ampersands &, etc.

In the HTML placed in Content Editor or Script Web Parts you can use server relative URLs for scripts such as /sites/team/_layouts/mySolution/myScript.js or page relative such as FolderInTheSamePagesLibrary/mySolution/myScript.js. When necessary, you can reference external scripts using the full absolute URL such as //cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js (note that the protocol schema http/https is omitted to support script placement on both secured and unsecured pages).

ASP.NET controls for Script Registration also provide you with replaceable tokens such as ~site and ~siteCollection but these can only be used in server-side page code: master pages, page layouts, user controls and ASPX pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.