Welcome Guest, Not a member yet? Register   Sign In
REST API webservices
#1

How to send multiple response using codeigniters RESTful Services
Ex :
$this->response($user_regdata);
$this->response($salary_data);
this way is not working only first response send ..
How to send multiple responses... at a time ?
Manikanta
Reply
#2

You don't, HTTP doesn't work that way.
Reply
#3

(01-22-2016, 06:48 AM)Narf Wrote: You don't, HTTP doesn't work that way.

Then how to send the multiple response at a time ...?
Manikanta
Reply
#4

(01-22-2016, 11:47 PM)Chandini Wrote:
(01-22-2016, 06:48 AM)Narf Wrote: You don't, HTTP doesn't work that way.

Then how to send the multiple response at  a time ...?

I'll repeat: You don't!
1 request = 1 response, that's how HTTP works. It's not CI's problem, nor something you just don't know how to do. It's just the way it is.
Reply
#5

(01-23-2016, 05:39 AM)Narf Wrote:
(01-22-2016, 11:47 PM)Chandini Wrote:
(01-22-2016, 06:48 AM)Narf Wrote: You don't, HTTP doesn't work that way.

Then how to send the multiple response at  a time ...?

I'll repeat: You don't!
1 request = 1 response, that's how HTTP works. It's not CI's problem, nor something you just don't know how to do. It's just the way it is.

Man...This forum is sometimes very frustrating to average programmers. Experts are playing mind games with us for no reason.

The question is very clear and easily implied:

What is the best way to update info via Rest API when the information is in a master detail relationship?

You have a table that has users and another table that has Salaries for users.

You want to update that info.

How?
Reply
#6

(This post was last modified: 01-23-2016, 12:34 PM by arma7x.)

From what I know, you only state one response code returned. Example, $this->response($book, 201); // Send an HTTP 201 Created. If you get the user data & salaries via POST then just use the value you get to process the request. If successful then return ok or vice versa. They're many HTTP status code.
Keep calm.
Reply
#7

(This post was last modified: 01-23-2016, 01:16 PM by skunkbad.)

(01-22-2016, 05:43 AM)Chandini Wrote: How to send multiple response  using codeigniters RESTful Services
Ex :
$this->response($user_regdata);
$this->response($salary_data);
this way is not working only first response send  ..
How to send multiple responses...  at a time ?


Maybe like this instead:


Code:
$this->response( array( 'reg_data' => $user_regdata, 'salary_data' => $salary_data ) );

Narf just isn't playing mind tricks with you; you only have one response. If you need to pass back multiple "responses", then you need to put them in an object, array, or some kind of container.

BTW, why do this? Many people are so bent on REST, they can't even get anything done. Especially if you're working with jQuery or other JS AJAX, you could just as easily echo some JSON:

Code:
echo json_encode( array( 'reg_data' => $user_regdata, 'salary_data' => $salary_data ) );

... and if you're trying to route requests with REST (because that's all you're really doing), I just think you're wasting your time. It's just an opinion, but remember that you're the one asking questions.
Reply
#8

(01-23-2016, 10:56 AM)LeMec Wrote:
(01-23-2016, 05:39 AM)Narf Wrote:
(01-22-2016, 11:47 PM)Chandini Wrote:
(01-22-2016, 06:48 AM)Narf Wrote: You don't, HTTP doesn't work that way.

Then how to send the multiple response at  a time ...?

I'll repeat: You don't!
1 request = 1 response, that's how HTTP works. It's not CI's problem, nor something you just don't know how to do. It's just the way it is.

Man...This forum is sometimes very frustrating to average programmers. Experts are playing mind games with us for no reason.

The question is very clear and easily implied:

What is the best way to update info via Rest API when the information is in a master detail relationship?

You have a table that has users and another table that has Salaries for users.

You want to update that info.

How?

I give direct answers to direct questions.

If you call that mind games, then the frustration will never end. Us "experts" don't have the magic power of knowing what you mean by asking the wrong questions.
Reply
#9

(01-23-2016, 02:02 PM)Narf Wrote:
(01-23-2016, 10:56 AM)LeMec Wrote:
(01-23-2016, 05:39 AM)Narf Wrote:
(01-22-2016, 11:47 PM)Chandini Wrote:
(01-22-2016, 06:48 AM)Narf Wrote: You don't, HTTP doesn't work that way.

Then how to send the multiple response at  a time ...?

I'll repeat: You don't!
1 request = 1 response, that's how HTTP works. It's not CI's problem, nor something you just don't know how to do. It's just the way it is.

Man...This forum is sometimes very frustrating to average programmers. Experts are playing mind games with us for no reason.

The question is very clear and easily implied:

What is the best way to update info via Rest API when the information is in a master detail relationship?

You have a table that has users and another table that has Salaries for users.

You want to update that info.

How?

I give direct answers to direct questions.

If you call that mind games, then the frustration will never end. Us "experts" don't have the magic power of knowing what you mean by asking the wrong questions

Indeed the frustration continues...But it will end when one finds another community and a different framework to work with,,,
Reply
#10

(01-23-2016, 02:02 PM)Narf Wrote:
(01-23-2016, 10:56 AM)LeMec Wrote:
(01-23-2016, 05:39 AM)Narf Wrote:
(01-22-2016, 11:47 PM)Chandini Wrote:
(01-22-2016, 06:48 AM)Narf Wrote: You don't, HTTP doesn't work that way.

Then how to send the multiple response at  a time ...?

I'll repeat: You don't!
1 request = 1 response, that's how HTTP works. It's not CI's problem, nor something you just don't know how to do. It's just the way it is.

Man...This forum is sometimes very frustrating to average programmers. Experts are playing mind games with us for no reason.

The question is very clear and easily implied:

What is the best way to update info via Rest API when the information is in a master detail relationship?

You have a table that has users and another table that has Salaries for users.

You want to update that info.

How?

I give direct answers to direct questions.

If you call that mind games, then the frustration will never end. Us "experts" don't have the magic power of knowing what you mean by asking the wrong questions.

I thought you were supposed to be a mind reader? Isn't that why you get paid the big bucks?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB