Skip to main content
the header is needed
Source Link
chuy
  • 11.2k
  • 28
  • 49

Ultimately the body can be extracted by using HTTPRequestData

HTTPRequestData[]

will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time).

obj = CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]]

URLExecute[obj, {}, 
  "Body" -> "test"\"test body"body\"",
  "Headers" -> {"content-type" -> "text/plain" (*or whatever is appropriate*)}, 
  Method -> "POST"]
"test body" 

If your API is actually attached to a form, and your header when making the request is something like:

Content-Type: multipart/form-data

you can use the following

CloudDeploy[APIFunction[{"i"-> "Image"}, #i &,"PNG"]]

This will echo back the image "i" (as labeled in your form). I put "PNG" for display purposes, you should change it to fit your needs.

Ultimately the body can be extracted by using HTTPRequestData

HTTPRequestData[]

will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time).

obj = CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]]

URLExecute[obj, {}, "Body" -> "test body", Method -> "POST"]
"test body" 

If your API is actually attached to a form, and your header when making the request is something like:

Content-Type: multipart/form-data

you can use the following

CloudDeploy[APIFunction[{"i"-> "Image"}, #i &,"PNG"]]

This will echo back the image "i" (as labeled in your form). I put "PNG" for display purposes, you should change it to fit your needs.

Ultimately the body can be extracted by using HTTPRequestData

HTTPRequestData[]

will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time).

obj = CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]]

URLExecute[obj, {}, 
  "Body" -> "\"test body\"",
  "Headers" -> {"content-type" -> "text/plain" (*or whatever is appropriate*)}, 
  Method -> "POST"]
"test body" 

If your API is actually attached to a form, and your header when making the request is something like:

Content-Type: multipart/form-data

you can use the following

CloudDeploy[APIFunction[{"i"-> "Image"}, #i &,"PNG"]]

This will echo back the image "i" (as labeled in your form). I put "PNG" for display purposes, you should change it to fit your needs.

just make it explicitly a POST
Source Link
chuy
  • 11.2k
  • 28
  • 49

Ultimately the body can be extracted by using HTTPRequestData

HTTPRequestData[]

will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time).

obj = CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]]

URLExecute[obj, {}, "Body" -> "test body"]body", Method -> "POST"]
"test body" 

If your API is actually attached to a form, and your header when making the request is something like:

Content-Type: multipart/form-data

you can use the following

CloudDeploy[APIFunction[{"i"-> "Image"}, #i &,"PNG"]]

This will echo back the image "i" (as labeled in your form). I put "PNG" for display purposes, you should change it to fit your needs.

Ultimately the body can be extracted by using HTTPRequestData

HTTPRequestData[]

will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time).

obj = CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]]

URLExecute[obj, {}, "Body" -> "test body"]
"test body" 

If your API is actually attached to a form, and your header when making the request is something like:

Content-Type: multipart/form-data

you can use the following

CloudDeploy[APIFunction[{"i"-> "Image"}, #i &,"PNG"]]

This will echo back the image "i" (as labeled in your form). I put "PNG" for display purposes, you should change it to fit your needs.

Ultimately the body can be extracted by using HTTPRequestData

HTTPRequestData[]

will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time).

obj = CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]]

URLExecute[obj, {}, "Body" -> "test body", Method -> "POST"]
"test body" 

If your API is actually attached to a form, and your header when making the request is something like:

Content-Type: multipart/form-data

you can use the following

CloudDeploy[APIFunction[{"i"-> "Image"}, #i &,"PNG"]]

This will echo back the image "i" (as labeled in your form). I put "PNG" for display purposes, you should change it to fit your needs.

added 76 characters in body
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

Ultimately the body can be extracted by using HTTPRequestData

HTTPRequestData[]

will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time).

obj = CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]] 

URLExecute[obj, {}, "Body" -> "test body"]
"test body" 

If your API is actually attached to a form, and your header when making the request is something like:

Content-Type: multipart/form-data

you can use the following

CloudDeploy[APIFunction[{"i"-> "Image"}, #i &,"PNG"]]

This will echo back the image "i" (as labeled in your form). I put "PNG" for display purposes, you should change it to fit your needs.

Ultimately the body can be extracted by using HTTPRequestData

HTTPRequestData[]

will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time).

CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]]

If your API is actually attached to a form, and your header when making the request is something like:

Content-Type: multipart/form-data

you can use the following

CloudDeploy[APIFunction[{"i"-> "Image"}, #i &,"PNG"]]

This will echo back the image "i" (as labeled in your form). I put "PNG" for display purposes, you should change it to fit your needs.

Ultimately the body can be extracted by using HTTPRequestData

HTTPRequestData[]

will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time).

obj = CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]] 

URLExecute[obj, {}, "Body" -> "test body"]
"test body" 

If your API is actually attached to a form, and your header when making the request is something like:

Content-Type: multipart/form-data

you can use the following

CloudDeploy[APIFunction[{"i"-> "Image"}, #i &,"PNG"]]

This will echo back the image "i" (as labeled in your form). I put "PNG" for display purposes, you should change it to fit your needs.

Source Link
chuy
  • 11.2k
  • 28
  • 49
Loading