Interview Questions API
Interview Questions API
sanAPI
AnAPIst andsbetweencli
entandser
verandi
tser
vicest
her
equestofcl
i
entandf
etcht
he
responsefrom ser
verandservet
hecli
ent.
2>CanweusePuti
nst
eadofPost?
Yeswecanuseputi
nst
eadofPostf
orcr
eat
ingai
nfor
mat
ioni
ntheser
ver.
Puti
sanidempot
entmet
hodt
hati
fresour
ceal
readyexi
sti
twillnotdoanythi
ngbutifwer
an
POSTagainwi
tht
hesamedat
aitwi
llgi
veaner
rorthatt
heresourceisal
readycr
eated.
3>Di
ffbwwebser
viceandAPI
AnAPIst
andsbet
weencl
i
entandser
verandi
tser
vicest
her
equestofcl
i
ent,
APIar
elesssecur
eandt
heyar
eav
ail
abl
etoev
ery
oneasmostoft
het
imet
heyar
epubl
i
c
Webser
vicesar
eakindofAPIonlybutt
heyar
emor
esecur
etheyar
elessaccessi
blet
opubl
i
c
andt
heyfoll
owsomestr
ict
errequi
rements
Al
lwebser
vicesar
eAPIbutal
lAPIar
enotwebser
vice
Awebservicei
sawebappl i
cati
oncomponentt
hatusessomest
andar
dfor
matl
i
keXMLandi
t
doesnothaveanyuseri
nter
face.
4>Maj
orchal
l
engesi
nAPIt
est
ing?
a.Therequestbodyiscomi
ngf
rom DBandmanydet
ail
sar
ebei
ngbl
ankov
ert
her
e,t
her
e
arenul
lvaluespr
esent
b.Theresponsegiv
enbyt
hedev
eloperi
snoti
nacor
rectf
ormatandt
heAPIsar
efai
l
ing
fort
hatreason
c. Somet i
mesthebodycont
ainswil
dchar
act
ers(
emoj
j
is,
languageswr
it
teni
nUni
codes)so
thatbecomesdi
ffi
cul
ttoval
idat
e.
5.Wher
etopassAPIkey?
Wepasst
heAPIkeyi
ntheheaderoft
heoft
her
equestbody,
I
npost
manwecanaddheaderwi
thx
-api
keyandputt
hev
alue
I
nAut
omat
ioncodewewi
l
lputt
hev
alueundergi
vensect
ion
6.Wher
etopasscl
i
entkeyandcl
i
enti
d?
Wepasst
hecl
i
entkeyandcl
i
enti
dint
heheaderoft
heoft
her
equestbody,
I
npost
manwecanaddheaderwi
thx
-api
keyandputt
hev
alue
I
nAut
omat
ioncodewewi
l
lputt
hev
alueundergi
vensect
ion.
Whatar
ethel
i
mit
ati
onsofAPIt
est
ing
I
nfr
ontendi
fther
ear
edesi
gnorcosmet
icer
rorwecannothandl
ethr
oughAPIt
est
ing
Weal
socannotdoaccessi
bil
i
tyt
est
ingorhowUserf
ri
endl
ytheappl
i
cat
ioni
swi
thAPIt
est
ing
Wecannotdoper
for
mancer
enderoft
hepage
Whati
sthedi
ffbwpat
handquer
ypar
am ?
Pathpar
ameterwil
lref
ert
ospeci
fi
cresour
cei
nser
verbutquer
ypar
amet
erwi
l
lgi
veur
esul
ts
wit
hsomefil
terval
ues
Weadd?
=inquer
ypar
amet
ersf
ormaki
ngt
her
esul
tst
obef
il
ter
ed
Whati
sthedi
ffbet
weenPUTandPATCH?
PUUgener al
lyupdatestheresourcepresenti
ntheserv
erandPATCHwi l
lupdat
ethe
i
nf or
mat i
onbutiftheal
readyresourceintheser
verdoesnotexi
stt
henputwil
lcr
eat
eanew
resourcebutpatchwil
lthrowaner r
or.
WhyPOSTi
sbet
tert
hanGET?
POSTi
smor esecur
eascomparedtoGETbecauset
hev
aluesar
enotbei
ngst
oredei
theri
nthe
br
owserhi
stor
yorintheser
verl
ogs.
Whati
sMockJson?
Supposethedevel
operhascreat
edanappl i
cati
onandtheresponseisstil
lnotav ai
l
abl
esowe
canwrit
eajsonwhichmaylookt otheori
ginalj
sonandwil
lwrit
et hetestscr
iptsaccor
dingt
o
thatt
henwewi l
lval
idat
eit,
oncet heor
igi
nal j
sonfi
l
eisavail
ablethenwewi llchanget
hedata
accor
dingl
y.
Whati
sst
ati
candDy
nami
cJSON?
JSOnf
il
eswhi
char
enotchangi
ngf
requent
lyar
ecal
l
edasSt
ati
cJSON
Weputthest
ati
cjsonfi
l
einourlocalf
ramewor
korint
heGI
Trepoandt
henweuse
r
eadAl
lByt
esmethodtofet
chthedetai
lsfr
om t
her
e.
ThoseJSOnwhi
chi
schangi
ngv
eryf
requent
lywecal
lthatasDy
nami
cJSON.
Weuseei
therPOJOcl
assorwecanal
sopar
amet
ri
zet
hedet
ail
sint
heAPIpay
loadbody