LogoLogo
API Status
  • 👋Welcome
  • 🌐What is Morpheus Platform?
    • Interoperability
  • â„šī¸Help
    • 📗Glossary
    • 🆘Support
    • Firewall problems
    • EULA
  • CREATION
    • 🎮Unreal Development
      • ⚡Get Started
        • âš’ī¸Download the Editor
        • âĢUpload Content
        • 🌎Creating your own map
        • 📝Morpheus Base Project
        • ❓Differences from Unreal
          • 🧍Character Configuration
        • 📡Morpheus Networking
          • Introduction to Morpheus Networking
          • Network Levels
          • Replicated Properties
          • RPCs
          • Morpheus Render Targets
          • Morpheus Array
          • Networking FAQ
          • Replicating Sublevels
      • 📚Features & Guides
        • 📒Example Plugin
          • Nameplates
          • In-game roles
          • Resizing
        • 🏊Actor Pooling
        • 🔊Audio
        • 🎭Avatars
          • Creating an Avatar
          • Attachments
            • MML Attachments
          • Custom Animation Variables
          • Importing an NFT collection
          • Capsules and Mesh Transforms
        • 🤖Bots
        • đŸŽ™ī¸Chat
          • Unreal Text Chat
        • đŸŽ›ī¸Control Panels
          • Control Panel Configuration
          • DJ booth mission control
          • Observer Controls
        • 🔉Crowd Audio
        • đŸ¤ŧCrowd Rendering
          • Legacy Animated Crowd
            • Animated Crowd Console Commands
            • Attaching static meshes to crowd members
          • Crowd Materials
          • Performance Parameters
          • Live Config Settings
          • Crowd Animation
            • Crowd Anim Blueprint
              • User Guide - Crowd Anim Blueprint
              • Reference Guide - ABP Nodes
                • Animation Playback
                • States and State Machines
                • Variables
                • Transitions
                • Special
                • Blends
                • Additional Notes
        • 🍱Helpers & Extras
          • "Instanced Objects" in Blueprints
          • Objects with "world context"
          • Making DataAsset classes
          • Duplicate Objects
          • The Bootflow Subsystem
          • The "Wait For Condition" System
          • Advanced Graphics settings
          • Listening to inputs on UObjects
          • Morpheus UserID
          • World Services
          • M2Extras: Skins System
        • đŸ–Ĩī¸Loading Screen
        • ⚡Live Config
          • Editing for a World
          • Editing Locally
          • Default Settings
          • Accessing via Blueprint
          • Adding New Settings
          • Overriding Defaults
          • Using Arrays
        • 🧊MML
        • đŸ•ēMotion Capture
        • 📡Networking
        • đŸ“ĸNotifications
        • Raycastable Crowd
        • 🌐Singletons
        • 📱Streaming & Multiplatform
          • GFN on mobile
        • đŸ–Ĩī¸UI
          • "UI Mode"
        • đŸ—ƒī¸User Collections
          • Creating a New Object Definition
          • Accessing from Unreal
            • Creating Objects Definitions
            • Transfer Objects
            • User Collection Views
            • Receiving Updates
        • đŸ“ēVideo Players
          • Embedded Video Player
          • Millicast video streaming
            • How to Setup an In-Game Video Stream
            • Picture-in-Picture mode
          • Streaming Video Player
            • How to Setup a URL Video Player
            • Picture-in-Picture mode
        • 🐞Visual Debugging
          • Inspector
        • đŸĒŸWeb UI
        • Online Services
          • KV Store Service
        • 💠Web Requests
          • Http Requests
            • Legacy HTTP Nodes
          • JSON Handling
          • WebSockets
          • Identity Validation
          • Allowed External URLs
          • Walkthrough Example
            • Example Counter Service
        • âœˆī¸World Travel
          • World Travel in the editor
        • Avatar Physics Assets
        • Action Gameplay Helper Components
      • 🔑Workflows
        • â†—ī¸Upgrade the Editor
          • đŸ–Ĩī¸Version History
        • âš™ī¸Editing Project Settings
        • 📈Profiling
        • đŸ§ēMarketplace Importing
        • đŸ› ī¸Extra Workflows
          • Setup Play-in-Editor
          • Setup Local Asset Validation
          • Adding Gameplay Tags
          • Validating Game Assets
          • Custom Connection Modes
          • Connect Editor to a World
          • Common Issues
      • 📚Useful Reading
        • ⭐Best Practices
    • 🌎Worlds
      • 📩Invite Players
        • Setting Role Groups
      • Persistent Worlds
      • Always on Worlds
    • 📅Running events
      • ✅Large scale events - Checklist
      • 👾Anti-Cheat (EAC)
      • 🎮Player Entry
        • 📱React Native
        • Steam
        • đŸ’ģHardware Reqs
      • đŸŽĨBroadcast
        • 📹OBS Integration
      • Failover
      • 🏁Capacity And Queue Management
  • ADMINS
    • đŸ‘ĒAccess Control
      • Adding metaverse contributors
      • Creating a new project
    • 💲Pricing
      • Development Support
      • Included Usage & Overages
      • Cloud Streaming
      • Access Modes
      • War Room Support
      • Platform SLA
    • âš™ī¸Settings
      • đŸ—ƒī¸Projects
  • APIs and Tooling
    • đŸ–Ĩī¸API Reference
      • Accounts
      • Events
      • Key/Value Store
      • Organizations
      • Realtime
      • User Profile
      • World Builder
      • Worlds
    • đŸ’ģTemplate Web App
      • đŸ’ĸModeration
    • Pixel Streaming
    • 🚀Launcher
  • Integrations
    • 📊Analytics
      • Sending events from web
      • 🎮Sending Events from Unreal
    • đŸ’ŦChat
      • 🎮Integrating Pubnub with your Unreal Project
      • Adding Moderation to Chat
Powered by GitBook
On this page
  • API Spec
  • Modelling the Request/Response in Unreal
  • Create an Actor to drive the logic
  • Making the Unauthenticated Requests
  • Making the Authenticated Requests

Was this helpful?

  1. CREATION
  2. Unreal Development
  3. Features & Guides
  4. Web Requests

Walkthrough Example

Making a call to your web api from Blueprint

PreviousAllowed External URLsNextExample Counter Service

Last updated 9 months ago

Was this helpful?

API Spec

Imagine you have a web service that has the following api:

Method + URL
Request/Response
Description

GET /api/counter

Response: { counter: number }

Returns a global counter shared by every user. Requires no authentication.

PUT /api/counter

Request: { value: number } Response: { counter: number }

Updates the shared counter by adding value from the request. Requires no authentication.

GET /api/counter/my

Response: { counter: number }

Returns a personal counter for the authenticated user. Required M2 Delegated token auth.

PUT /api/counter/my

Request: { value: number } Response: { counter: number }

Updates the personal counter by adding value from the request. Required M2 Delegated token auth.

Modelling the Request/Response in Unreal

In the Unreal Editor, create Blueprint USTRUCT definitions for the request / response objects.

S_HttpTaskExampleGetResponse

This defines the response back from your API.

S_HttpTaskExamplePutRequest

This defines the request to the PUT api.

Create an Actor to drive the logic

Create a Morpheus Actor with some interactable behaviour. Doing this is out of scope of this section, as it's very much dependent on what you are trying to do.

Your actor could be a control panel, an Interactable object or anything in between.

Making the Unauthenticated Requests

On some trigger (eg: a user pushing a button) hook up the Http Get Json node

The relevant "Update Counter Value" implementation can look as follows:

In this example, we are reading the JSON object required by the node into a variabled that's typed to the response (eg: S_HttpTaskExampleGetResponse).

You can then Break the struct to extract any data you need; for this example you can print to a debug message.

Making the PUT request is similar, but it requires you to pass a Json Object.

To do this, you can use the "Make Json Object from Struct" node to take your input and serialize it to JSON.

The result handling is the same as before.

You should be in a position to make GET and PUT requests to your counter service and get the results back.

Making the Authenticated Requests

Authenticated requests are the same process except for three small changes:

  • You need to set an "Auth Context"

  • You should ideally set a scope (eg: World)

  • You should tick the "Include Delegated Auth Token" option

A note on Auth Contexts. Auth Contexts determine how we pick up the identity of the actor making the request. For example, if a client is making the request via an interaction, this Auth Context will always be the Morpheus Actor (or an attached Morpheus Actor component) owned by that client. For a server, it can be the Authorative actor (assuming it is running with server authority). Auth Contexts are local to the client/server and cannot be executed remotely; eg: you cannot make a http request using the Auth Context of another actor you're not authoritative over.

Here's an example of the GET request set to use identity.

In this case, the Auth Context is the local player's actor that's provided as the Interaction Instigator.

Here's an example of the same GET but on the server.

In this example, the action is being fired via a Server RPC (eg: it's acting on the server). As a result, we can use "self" as the Auth Context because the actor itself is server authoritative.

🎮
📚
đŸ’