0

I am building restful api for android app using postman, but in postman only get method is working complete code is here https://github.com/arvindsinghs/GT/blob/master/apicontroller this method work if i sent parameters $atts = \Yii::$app->request->get();

method working

but if it changed it to post method and try to send paramerts in body it is not working $atts = \Yii::$app->request->post();

sending in form body

Any help is appreciated.

24 coded
  • 41
  • 5
  • In Postman don't fill your params into Params Tab, fill them in Body. PostMan consider them there as a sent form – noah_abou May 14 '20 at 05:43
  • @noah_abou params are empty in post , see this please https://prnt.sc/sgg5tc – 24 coded May 14 '20 at 05:52
  • But it shows that an email was sent and that it's not found in the DB ? Anyway just to be sure, get your postData into a variable and show it to see what's recieving: $postData = yii::$app->request->post(); var_dump($postData); exit; – noah_abou May 14 '20 at 05:57
  • @noah_abou did the same as you advised and here array is empty https://prnt.sc/sgg9f3 – 24 coded May 14 '20 at 06:00
  • Can you post the code the resetPassword Action ! – noah_abou May 14 '20 at 06:02
  • Also just try to echo anything just to see if the route is actually working: function actionResetPassword(){ echo "test text"; exit(); ...} – noah_abou May 14 '20 at 06:04
  • @noah_abou route is working fine https://prnt.sc/sggbux – 24 coded May 14 '20 at 06:05
  • Let me see to code then – noah_abou May 14 '20 at 06:08
  • @noah_abou, please check code here https://github.com/arvindsinghs/GT/blob/master/apicontroller – 24 coded May 14 '20 at 06:15
  • Wierd.. is the crsf disabled ! public $enableCsrfValidation = false; in the begining of the class. before you do that, add that backslach before yii and try again: \Yii::$app->request->post() – noah_abou May 14 '20 at 06:23
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/213839/discussion-between-24-coded-and-noah-abou). – 24 coded May 14 '20 at 06:25
  • this means that your API does not recognize content-type: multipart/form-data. which is normal. form-data values are sent as a block of data ("body part"). e.g. from form requests. – Julius Limson May 14 '20 at 07:53
  • @JuliusLimson, how can I resolve this content type issue – 24 coded May 14 '20 at 10:46
  • @JuliusLimson sent data in multi part https://prnt.sc/sgnxkf – 24 coded May 14 '20 at 12:20

0 Answers0