Giter VIP home page Giter VIP logo

Comments (6)

Viincenttt avatar Viincenttt commented on May 27, 2024

Hi Owin,

Here's an example I copied from one of my real life projects:

[HttpPost]
public async Task<ActionResult> ProcessPayment(string id) {
    await this._paymentService.ProcessPayment(id);
    return new HttpStatusCodeResult(HttpStatusCode.OK);
}

Your code looks fine to me. Is this a production or a test environment? Make sure your site publicly available on the internet and isn't blocked by a firewall or something.

You could also try to post a payment id to your site yourself to see if that also gives the same 502 error.

from mollieapi.

owingruters avatar owingruters commented on May 27, 2024

Thanx!

It's a test environment. It is publicly available in the cloud, so there
should not be a firewall.
It is also getting reached, because my code is firing and handled, only
the response is not correct.

I see a difference between our codes is that you use an actionresult where
I have used an HttpResponseMessage. I changed it and now I only get 1 call,
so I think they now recieve correct responsecode. Thanx!

Owin

On Fri, Aug 5, 2016 at 10:46 AM, Vincent Kok [email protected]
wrote:

Hi Owin,

Here's an example I copied from one of my real life projects:

[HttpPost]public async Task ProcessPayment(string id) {
await this._paymentService.ProcessPayment(id);
return new HttpStatusCodeResult(HttpStatusCode.OK);
}

Your code looks fine to me. Is this a production or a test environment?
Make sure your site publicly available on the internet and isn't blocked by
a firewall or something.

You could also try to post a payment id to site yourself to see if that
also gives the same 502 error.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#9 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALCR14anBwAzg-thPKtKcjXyn1hFU-qxks5qcvhngaJpZM4Jddgc
.

from mollieapi.

Viincenttt avatar Viincenttt commented on May 27, 2024

Good to hear it's working.

from mollieapi.

DianaLaa avatar DianaLaa commented on May 27, 2024

Sorry to open such an old topic, but could someone help please?

I've tried everything from [FromBody] to just plain string and whatever I do, Mollie gets a 404.

// Nope
[HttpPost]
public HttpResponseMessage Post(string id)
{
    return new HttpResponseMessage(HttpStatusCode.OK);
}

// Nope
[HttpPost]
public HttpResponseMessage Post([FromBody] string id)
{
    return new HttpResponseMessage(HttpStatusCode.OK);
}

When I completely remove the id parameter from my method, then Mollie can call it. But obviously, then I don't have the paymentId! :(

// Works, but no id :(
[HttpPost]
public HttpResponseMessage Post()
{
    return new HttpResponseMessage(HttpStatusCode.OK);
}

My routing is just default, shouldn't be a big deal right?

config.Routes.MapHttpRoute(
   name: "DefaultApi",
   routeTemplate: "api/{controller}/{id}",
   defaults: new { id = RouteParameter.Optional }
);

Can anyone shed some light on this? I'm pulling my hair out....

from mollieapi.

Viincenttt avatar Viincenttt commented on May 27, 2024

Looks like it might be a routing issue. Are you able to post to the API controller method yourself? You can test using using a simple plugin such as Postman (https://www.getpostman.com/)

from mollieapi.

DianaLaa avatar DianaLaa commented on May 27, 2024

Hi Vincent,

thank you kindly for your reply.

I've been using Postman, but I am struggling to figure out what to enter for the body:

  • form-data entering key: "id" and value: "test" fails magnificently with an UnsupportedMediaTypeException
  • raw fares no better: If I enter "test", my action is called :) but [FromBody] string id is still null :(
  • Update: Raw with input "{ "id": "test" }" => [FormBody] string id still null

Do you know what the exact format is?

I wish they'd just chosen a querystring parameter.... Would be so much easier.

Final update
Found it!

  1. Set body to "raw" and type to "JSON (application/json)"
  2. Use as body: { id: "test" } (I'm a doofus)
  3. Don't use [FromBody]string id, but create a dedicated object to hold a property:
        public class PaymentId
        {
            public string id { get; set; }
        }

        [HttpPost]
        public HttpResponseMessage Post([FromBody]PaymentId id)
        {
            return new HttpResponseMessage(HttpStatusCode.OK);
        }

from mollieapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.