Making a REST API call with nested options

I'm trying to implement the Stripe REST API for creating a card token:

https://stripe.com/docs/api/tokens/create_card?lang=dotnet

The syntax for that API is as follows:

var options = new TokenCreateOptions {
  Card = new CreditCardOptions {
    Number = "4242424242424242",
    ExpYear = 2020,
    ExpMonth = 5,
    Cvc = "123"
  }
};

var service = new TokenService();
Token stripeToken = service.Create(options);

Please note that the call makes use of nested options, i.e. all of the primary input parameters are actually nested under a "Card" option.

How do I implement this REST API call using OutSystems?

Thanks,
Kirk

Solution

Hi Kirk,

The stripe API has an OpenAPI (swagger) definition:

 https://github.com/stripe/openapi/blob/master/openapi/spec2.json

You could save it as a swagger.json file and than use that to let outsystems generate the methods for you to consume it. 

If OutSystems is not able to interpreter the swagger definition then you could try to install forge component 

https://www.outsystems.com/forge/component-overview/1270/swaggerproxy and try it with that.

Regards,

Daniel

Solution

And some more background info on how to consume REST APIs in OutSystems can be found at:

https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/REST/Consume_REST_APIs

Hi Kirk Sealls,

If you want to use for mobile then you can refer the below component on Forge:

Stripe Plugin :

https://www.outsystems.com/forge/component-overview/5399/stripe

Stripe Plugin Sample:

https://www.outsystems.com/forge/Component_Overview.aspx?ProjectId=5400


Cheers,

Assif

Daniël Kuhlmann wrote:

Hi Kirk,

The stripe API has an OpenAPI (swagger) definition:

 https://github.com/stripe/openapi/blob/master/openapi/spec2.json

You could save it as a swagger.json file and than use that to let outsystems generate the methods for you to consume it. 

If OutSystems is not able to interpreter the swagger definition then you could try to install forge component 

https://www.outsystems.com/forge/component-overview/1270/swaggerproxy and try it with that.

Regards,

Daniel

Hi Daniël,

I'm feeling super ignorant here, but I don't see any means via the UI to directly consume a swagger.json file, the only input it appears to accept is the base URL for the API methods (the "REST API URL"):


When you say that I can "save it [spec2.json] as a swagger.json file and than use that to let outsystems generate the methods...", how do I go about consuming that swagger.json file?

Thanks,
Kirk


Kirk Sealls wrote:

Daniël Kuhlmann wrote:

Hi Kirk,

The stripe API has an OpenAPI (swagger) definition:

 https://github.com/stripe/openapi/blob/master/openapi/spec2.json

You could save it as a swagger.json file and than use that to let outsystems generate the methods for you to consume it. 

If OutSystems is not able to interpreter the swagger definition then you could try to install forge component 

https://www.outsystems.com/forge/component-overview/1270/swaggerproxy and try it with that.

Regards,

Daniel

Hi Daniël,

I'm feeling super ignorant here, but I don't see any means via the UI to directly consume a swagger.json file, the only input it appears to accept is the base URL for the API methods (the "REST API URL"):


When you say that I can "save it [spec2.json] as a swagger.json file and than use that to let outsystems generate the methods...", how do I go about consuming that swagger.json file?

Thanks,
Kirk


I just figured out how to use SwaggerProxy (I had embarrassingly been trying to use it as a plugin). I still can't consume the REST API (now OutSystems simply isn't generating any APIs, even though no exception is being thrown), but I'm considering my original question answered.