tryPut

inline suspend fun <B, R> ApiFetcher.tryPut(apiPath: String, body: B, headers: Map<String, Any>? = FetchDefaults.Headers, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null, bodySerializer: SerializationStrategy<B> = serializer(), responseDeserializer: DeserializationStrategy<R> = serializer()): R?(source)

Like put, but returns null if the request failed for any reason.

Additionally, if ApiFetcher.logOnError is set to true, any failure will be logged to the console. By default, this will be true for debug builds and false for release builds.

Parameters

body

The body to send with the request. Make sure your class is marked with @Serializable or provide a custom bodySerializer.


inline suspend fun <R> ApiFetcher.tryPut(apiPath: String, headers: Map<String, Any>? = FetchDefaults.Headers, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null, responseDeserializer: DeserializationStrategy<R> = serializer()): R?(source)

A serialize-friendly version of tryPut that has no body but expects a serialized response.


inline suspend fun <B> ApiFetcher.tryPut(apiPath: String, body: B, headers: Map<String, Any>? = FetchDefaults.Headers, redirect: RequestRedirect? = FetchDefaults.Redirect, abortController: AbortController? = null, bodySerializer: SerializationStrategy<B> = serializer()): ByteArray?(source)

Deprecated

DO NOT IGNORE. Please change to `tryPutBytes` instead. This method will be modified soon in a backwards incompatible way, in order to support additional cases that the current form doesn't support.

Replace with

tryPutBytes(apiPath, body, headers, redirect, abortController, bodySerializer)

A serialize-friendly version of tryPut that expects a body but does not expect a serialized response.