Examples of Rest annotation

#1

Could you give some examples of the usage of Rest annotation?

0 Likes

#2

Here is an example of using REST to communicate with Marketo APIs

@rest(url=‘c3Vault:marketo.rest’)
type MarketoRest mixes REST {

/**

  • Retrieves Marketo REST API authentication token
  • URL: /oauth/token?grant_type=client_credentials&client_id=<custom_service_client_id>&client_secret=<custom_service_client_secret>
  • @param grantType
  •       Value should always be client_credentials
    
  • @param clientId
  •       Marketo Custom Service's client id
    
  • @param clientSecret
  •       Marketo Custom Service's client secret
    
  • @return object that contains access_token, expires_in, etc
    */
    @rest(uri=‘identity/oauth/token’, method=‘GET’)
    getAuthToken: private function(@rest(parameterName=‘grant_type’)
    grantType: string,
    @rest(parameterName=‘client_id’)
    clientId: string,
    @rest(parameterName=‘client_secret’)
    clientSecret: string): AuthenticationTokenResponse

}

0 Likes