Overview

In the following article, I described how to create new content.

This time, I’ll try updating and deleting existing content.

Filtering Items

With the following program, you can retrieve registered content. This time, I retrieved content with the title “Pre-update title.” res["data"] is an array.

uphq}iffferrlsaoutioineeesseelrld=snrstrmttp(nwy"_ekfeor=rao=ttreirieemr=iysyl_nqrsed"tp,tstu.[x{le=etej'==xevrr=ssdx"=[astoa""":]l.=fsntxx"ua'.(axx"aep'{g)'xxrp&he]""tie'ot)inn.s(cdjtelq(o}neufi/d"e'njprf(so"yifoi.linnitlattetp,ereim[r/hs{sne(k)oa)edd:yee}/r]{s=i={thveeamal_duteeyr}ps'e,)}?a{uftihl=t(eurs_esrtnra}m'e,password))

Getting the ID of the Content to Update

An ID like 730f844d-b476-4485-8957-c33fccb7f8ac is obtained.

iitteemm_=idre=s[i'tdeamt[a''i]d['0]]

Updating

Specify the type and id to update.

p}urrar.yl=jlso"}=roadendafq(t"u)=a"""}{e"tiahs{:ydtotp"tss{e:r"t."it}p:ibi/atutjtfetlsc"meeohn_s"n(oi":audd:pre,"il-{/,-n{ohideteae/dm{e_irt"tsye=pmhe_e}ta"yd,peer}s/,{iatuetmh_=i(du}s"ername,password),json=payload)

Deleting

Deletion can be executed as follows.

requests.delete(url,auth=(username,password))

Summary

I hope this serves as a useful reference when editing content on Drupal programmatically.