You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Something I just realized: PUT, POST and PATCH will silently remove empty fields in an encoded request body, due to the following line in body_config:
if (!is.list(body)) {
stop("Unknown type of `body`: must be NULL, FALSE, character, raw or list",
call.=FALSE
)
}
body<- compact(body) # <---- right here# Deal with three ways to encode: form, multipart & jsonencode<- match.arg(encode)
Most of the time this is harmless, but sometimes the presence or absence of a field can be meaningful, eg an empty field means "delete this component" whereas leaving it out means "leave this component unchanged".
Can these verbs have an option to keep empty fields in the request body? Or if development work is switching to httr2, provide this option in the new package.
The text was updated successfully, but these errors were encountered:
You can pass empty parts in body with httr if you use raw or character body.
There is a question on this in #561. Here some example code I have made there:
The encode = "raw" is not needed really because character body will stay as is, but it helps remember.
Using jsonlite externaly to httr to build the body is the main way to customise the body.
Could this fill your needs for empty body fields ?
Something I just realized:
PUT
,POST
andPATCH
will silently remove empty fields in an encoded request body, due to the following line inbody_config
:Most of the time this is harmless, but sometimes the presence or absence of a field can be meaningful, eg an empty field means "delete this component" whereas leaving it out means "leave this component unchanged".
Can these verbs have an option to keep empty fields in the request body? Or if development work is switching to httr2, provide this option in the new package.
The text was updated successfully, but these errors were encountered: