Merge two different API calls into One
Posted
by
dhilipsiva
on Programmers
See other posts from Programmers
or by dhilipsiva
Published on 2013-10-07T07:03:24Z
Indexed on
2013/10/27
10:14 UTC
Read the original article
Hit count: 341
I have two different apps in my django project. One is "comment" and an other one is "files". A comment might save some file attached to it.
The current way of creating a comment with attachments is by making two API calls. First one creates an actual comment and replies with the comment ID which serves as foreign key for the Files. Then for each file, a new request is made with the comment ID.
Please note that file is a generic app, that can be used with other apps too. What is the cleanest way of making this into one API call?
I want to have this as a single API call because I am in a situation where I need to send user an email with all the files as attachment when a comment is made. I know Queueing is the ideal way to do it. But I don't have the liberty to add queing to our stack now. So this was the only way I could think of.
© Programmers or respective owner