OCLOperators RestPost
No edit summary
No edit summary
Line 1: Line 1:
===== Rest =====
===== Rest =====
RestPost and RestGet and RestDownload are all operators on the selfVM variable only available in ViewModels.
[[OCLOperators RestGet|RestGet]], [[OCLOperators RestPost|RestPost]], RestPut, RestDelete and [[OCLOperators RestDownload|RestDownload]] are all operators on the selfVM variable only available in ViewModels.


These operators enables you to get or put information into external REST based services.
These operators enables you to get or put information into external REST based services.


These operators work by giving a ViewModel Nesting/Class that has data and additional Headers.
These operators works by adding a ViewModel Nesting/Class that has data and additional headers.


===== General rules and how to use headers in http and rest =====
===== General rules and how to use headers in http and rest =====
Please read about the difference about request headers and content headers.
Please read about the difference about request headers and content headers. https://en.wikipedia.org/wiki/Representational_state_transfer


==== Nesting columns starting according to ====
==== Nesting columns starting according to ====

Revision as of 14:54, 17 March 2019

Rest

RestGet, RestPost, RestPut, RestDelete and RestDownload are all operators on the selfVM variable only available in ViewModels.

These operators enables you to get or put information into external REST based services.

These operators works by adding a ViewModel Nesting/Class that has data and additional headers.

General rules and how to use headers in http and rest

Please read about the difference about request headers and content headers. https://en.wikipedia.org/wiki/Representational_state_transfer

Nesting columns starting according to

For Content

  • STRINGCONTENT If the there's a column named then the request will be filled with StringContent(value as string)
  • FILENAME_xxx then the value if used as filename in a MultipartFormDataContent expecting a xxx column with byte data for the file content
  • HEADER_xxx then the value is added to the content as Headers.Add(xxx,value)
  • HEADERMINUS_xxx then the value is added to the content with the name underscores converted to dashes. I.e. as Headers.Add(xxx.Replace('_','-'),value)

The default content is MultipartFormDataContent, (values as dictionary) for example used in the Oauth2 implementation for server to server authentication

Also, note that content can only be sent in REST POST and PUT.

For the Request

  • DEFAULTREQUESTHEADER_xxx then the value is added to the request as client.DefaultRequestHeaders.Add(xxx,value)
  • DEFAULTREQUESTHEADERMINUS_xxx then the value is added to the request with the name underscores converted to dashes. I.e. as client.DefaultRequestHeaders.Add(xxx.Replace('_','-'),value)
  • FORCEREQUESTCONTENTTYPE can be used to force adding a Content Type header to GET request. Is it needed by some frameworks, but is actually an invalid request. It's implemented as adding a empty content and adding a header to that empty content.

See further description here Rest Services In MDriven

This page was edited 2 days ago on 03/26/2024. What links here