Naviga Writer
6.3.3
6.3.3
  • Naviga Writer
  • Release notes
    • 6.3.3
    • 6.3.2
    • 6.3.1
    • 6.2.1
    • 6.2.0
    • 6.1.2
    • 6.1.1
    • 6.1.0
    • 6.0.0
    • 5.3.0
  • Introduction
    • Authoring
    • Developing
    • Publishing
    • User stories and reference cases
  • User Guide
    • Writer User Guide
      • The Content Area and Tabs
        • Help menu
        • Language menu
        • Article name
        • Writing teasers
        • Content area
        • Information
        • Search and replace words
        • History Button
        • Save and publish flow
        • Tabs
          • Meta Tab
            • Author
            • Channels
          • Integrations Tab
          • Image and Article search Tab
        • Locked article
      • Text management
      • Writer Keyboard Shortcuts
      • Personal Writer template
      • Channels to control access
      • Images User Guide
      • Common questions when starting using Writer
  • Admin Guide
    • Configuration files
    • Configurations Guide
    • Configuration of Writer templates
    • Publish Flow
      • Default configuration definitions
      • Starting part of the configuration
      • Publish flow config details
      • Configuration of calendarLocale
      • Preconditions for roles in the publish flow
    • Generic properties for Objects
      • Generic properties configuration
    • Image Services
      • Photo uploader
      • Binary Service Light
      • ImEngine
      • Imgix
    • Available Plugins
      • Naviga developed plugins
        • Plugins in earlier versions of Writer
      • Third-party plugins
  • Developer guide
    • Writer plugin development
      • Quickstart
      • Plugin overview
      • Creating an content object plugin
      • Validation and hooks
      • Interacting with external resources
    • Writer Plugin Building Blocks
      • Package
      • Component
      • Node
      • Converter
      • Events
    • Writer plugin style guide
      • CSS Guidelines
      • CSS variables, colors and fonts
      • UI Components
    • Tutorials
      • Popover & text analysis
      • Search & replace
      • Concept interaction
    • Infomaker NewsML
      • Overview
      • Document relations and types
      • Extensions XSD
      • NewsItem
      • ConceptItem
      • PlanningItem
      • Examples
        • NewsItem - Text
        • NewsItem - Picture
        • NewsItem - PDF
        • ConceptItem - Author
        • ConceptItem - Category
        • ConceptItem - Channel
        • ConceptItem - Content Profile
        • ConceptItem - Event
        • ConceptItem - Organisation
        • ConceptItem - Person
        • ConceptItem - Place (point)](point)](point)](point)](point)](point)](point)](point)](point)](point)]
        • ConceptItem - Place (polygon)](polygon)](polygon)](polygon)](polygon)](polygon)](polygon)](polygon)]
        • ConceptItem - Section
        • ConceptItem - Story
        • ConceptItem - Topic
        • PlanningItem
    • Media Enrichment
      • Images
  • API Reference
    • Writer Api
      • Api
      • Article
      • Browser
      • Concept
      • ConceptService
      • Document
      • Events
      • NewsItem
      • Router
      • Ui
      • Upload
      • User
      • settings
    • UI Components
      • UIAvatar
      • UIButton
      • UIByline
      • UICheckbox
      • UIChip
      • UIDatePicker
      • UIDatetimeFieldEditor
      • UIDropdown
      • UIFieldEditor
      • UIIconButton
      • UIInlineImage
      • UIPagination
      • UISelect
      • UITimePicker
      • UIToggle
      • UITooltip
      • UIInputText
      • UITextarea
Powered by GitBook
On this page
  • path and parameters specification
  • Simple GET of external resource
  • Simple POST to external resource
  • Simple request of external resource with added header
  • POST with Authorization header using resourceproxy
  • GET with Authorization header using resourceproxy

Was this helpful?

  1. Developer guide
  2. Writer plugin development

Interacting with external resources

Digital Writer includes a resource proxy which enables plugins to make HTTP requests to external resources, even when the Writer is hosted in an IP-locked environment.

In order to reach an external source the plugin should use the built in Router-instance which is exposed on the writer.router-property. This router-property contains functions for the normal HTTP methods, get() post(), del(), and put().

  • api.router.post(string path, object parameters)

  • api.router.put(string path, object parameters)

  • api.router.get(string path, object parameters)

  • api.router.del(string path, object parameters)

path and parameters specification

  • path is a string which should point to an internal Writer API resource. For the purposes

    of interacting with external sources, path should be '/api/resourceproxy'

  • parameters is an object which is converted to a querystring and is appended to the path parameter.

    • Use the url-property to define which external resource to fetch

    • The headers, and body-properties are forwarded to the external resource

    • Add a x-append-authorization-property to headers-property to forward any Authorization

      information to the external resource

Simple GET of external resource

import {api} from 'writer'

api.router.get('/api/resourceproxy', { url: 'https://my-external-url.com' })
    .then(response => api.router.checkForOKStatus(response))
    .then(response => api.router.toJson(response))
    .then(json => {
        // Handle json data
    })

Simple POST to external resource

import {api} from 'writer'

api.router.post('/api/resourceproxy', {
    url: 'https://my-external-url.com',
    body: JSON.stringify({
        property: 'value'
    }),
})
    .then(response => api.router.checkForOKStatus(response))
    .then(response => api.router.toJson(response))
    .then(json => {
        // Handle json data
    })

Simple request of external resource with added header

import {api} from 'writer'

api.router.get('/api/resourceproxy', { 
    url: 'https://my-external-url.com',
    headers: {
        'x-my-header': 'my-header-value'
    }
})
    .then(response => api.router.checkForOKStatus(response))
    .then(response => api.router.toJson(response))
    .then(json => {
        // Handle json data
    })

POST with Authorization header using resourceproxy

import {api} from 'writer'

api.router.post('/api/resourceproxy', {
    url: 'https://my-protected-external-url.com',
    body: JSON.stringify({
        property: 'value'
    }),
    headers: {
        'x-append-authorization': 'Basic YWxhZGRpbjpvcGVuc2VzYW1l'
    }
})
    .then(response => api.router.checkForOKStatus(response))
    .then(response => api.router.toJson(response))
    .then(json => {
        // Handle json data
    })

GET with Authorization header using resourceproxy

import {api} from 'writer'

api.router.get('/api/resourceproxy', {
    url: 'https://my-protected-external-url.com',
    headers: {
        'x-append-authorization': 'Basic YWxhZGRpbjpvcGVuc2VzYW1l'
    }
})
    .then(response => api.router.checkForOKStatus(response))
    .then(response => api.router.toJson(response))
    .then(json => {
        // Handle json data
    })
PreviousValidation and hooksNextWriter Plugin Building Blocks

Last updated 5 years ago

Was this helpful?