DEV Community

Andrew Petersen
Andrew Petersen

Posted on

3 1

SharePoint Rest API Formatter

Before stumbling across the article, Userscripts Are Fun And Are Still Very Much Relevant, I had never heard of Userscripts. They are pretty useful; kind of like a bare bones browser extension.

The first thing I created was a helper to format and syntax highlight the XML that comes back when navigating to a SharePoint REST endpoint in Chrome or Edge.

Userscript automatically kicks in on all REST API urls
End Result

Without it, it'd look like this
Raw XML Response

Previous Solutions/Attempts

  • I've installed Chrome Extensions to automatically format/syntax highlight XML, but they perform mediocre at best
  • I've experimented with Chrome Extensions to automatically set the request headers to application/json, but that inevitably causes problems when I forget to turn it off, and sometimes I prefer the ATOM/XML response because it shows you what child properties you can expand on.

Goals

  1. Format and syntax highlight the XML response
  2. Provide a toggle to switch between XML or JSON response

Install Steps

  1. Install the ViolentMonkey Chrome Extension
    • This is what manages all your Userscripts.
    • It's a weird name, but it has worked great so far.
  2. Add a new User Script from URL
    • Open the ViolentMonkey extension Dashboard,
    • Then click "New Script from Url" and paste in the following url.
    • It's the raw url to this Gist, which is the result of my efforts. Definitely take a look at the code if you're interested.
https://gist.githubusercontent.com/DroopyTersen/7234e172ba004a5689910f05822a1b95/raw/a0a7e03c47daa55ef7a34ac433f6231fdb0e9bb5/REST%2520API%2520Formatter%2520Userscript

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay