Search code examples
restasp.net-web-apirestful-architecturehttp-verbs

Assign a ressource should be what http verb in a REST API


I am doing attach and detach operations in my below controller like detaching the relationship from a OU to a ModuleDevice.

What http verbs would those operations mean in a REST API?

ModuleDevicesToOUController

Api/ModuleDevicesToOU/1/OU/1 // Attach for ModuleDevice with Id 1 the OU with Id 1
PUT/Delete/Patch ??? Attach…

Api/ModuleDevicesToOU/1/OU/1// Detach for ModuleDevice with Id 1 the OU with Id 1
PUT/Delete/Patch ??? Detach…

Solution

  • How about using the LINK method? https://datatracker.ietf.org/doc/html/draft-snell-link-method-08

    If that's a little experimental for you then just use POST.