skip to Main Content

I am developing a iOS app like eBay. For this web service developer is using Magento. He developed the web service for Login. Following are the situations :

1) If I send valid login credentials , he returns me logged in used info in response + a flag as result = true & in this case http status code is 200.

2) If I send wrong password , he returns me a flag as result = false & http status code is 200.

Basically I don’t want to depend on result flag because , if developer changed the result flag name then iOS app can’t recognize that. So I want to follow standards which is a http status codes.

My question is , in 2nd situation is it right to send 200 as http status code ? I think he should send me 401 ? Correct me if I am wrong.
If I am right , is there any way to send http status code from php code so that I can check the http status code on iOS side ?

2

Answers


  1. My question is , in 2nd situation is it right to send 200 as http status code ? I think he should send me 401 ? Correct me if I am wrong.

    That depends on your needs. Write the specification, then implement accordingly. If you say 401, take 401.

    If I am right , is there any way to send http status code from php code so that I can check the http status code on iOS side ?

    Sure, there is. Luckily this has been asked before so the info is already on this website and we do not need to answer it again.

    Login or Signup to reply.
  2. You can add custom response status code in Magento by,

    $this->getResponse()->setHeader('HTTP/1.0','404',true);
    $this->getResponse()->setHeader('HTTP/1.0','200',true);
    

    where $this is controller action object, code works in your magento controller

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search