OneDrive Expects Boundary for Content-Type: application/json - onedrive

This is a recent development. We run integration tests against this API on every commit.
POST https://apis.live.net/v5.0/me/skydrive
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json
{
"name": "My example folder"
}
Response:
{
"error": {
"code": "request_header_invalid",
"message": "The header 'Content-Type' is missing the required parameter: 'boundary'."
}
}
Requiring a boundary for an application/json content-type is just wrong. But lets try it:
POST https://apis.live.net/v5.0/me/skydrive
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json; boundary=idontactuallybelonghere
{
"name": "My example folder"
}
Response:
{
"error": {
"code": "request_header_invalid",
"message": "The header 'Content-Type' is missing the required parameter: 'boundary'."
}
}

Are you trying to create a folder? That error sounds like it thinks you're trying to upload a file using a multipart/form-data POST.
Are you using the exact URL as in your example? I tried that exact request against my account and it worked. I was able to reproduce your error, though, by using a URL that ends in '/files' like I would for a file upload.

Related

insert multiple rows in a data extension by using rest api

I'm trying to insert multiple rows in my data extension by using a POST request on postman. I'm using this documentation :https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/postDataExtensionRowsetByKey.html.
Details of my first POST request :
My URL :
https://MY_SUBDOMAIN.auth.marketingcloudapis.com/v2/token
My body (by using the informations of the package created on marketing cloud) :
{
"client_id": "ssd6ssd6ssd6ssd6ssd6ss",
"client_secret": "p3sp3sp3sp3sp3sp3sp3sp3",
"account_id": "7842222",
"grant_type": "client_credentials"
}
I send the request => Status 200 OK
I copy the tokken access.
I create a second POST request.
Tab Authorization, Type = Bearer Token, I paste my token access
Details of my second POST request :
My URL :
https://MY_SUBDOMAIN.rest.marketingcloudapis.com/hub/v1/dataevents/key:EXTERNAL_KEY_OF_MY_DATA_EXTENSION/rowset
My body :
`
Host: https://MY_SUBDOMAIN.rest.marketingcloudapis.com
POST /hub/v1/dataevents/EXTERNAL_KEY_OF_MY_DATA_EXTENSION/rowset
Content-Type: application/json
[
{
"keys":{
"ID_Crawl": "test123"
},
"values":{
"Source": "2013-05-23T14:32:00Z",
"Type_contenu": "no",
"Statut_Notification": "non lu",
"Champ": "20081105",
"Origine_contenus": "test blablablablablablabla",
"Date_crawl": 02/02/2023
}
},
{
"keys":{
"ID_Crawl": "test"
},
"values":{
"Source": "2013-05-23T14:32:00Z",
"Type_contenu": "ok",
"Statut_Notification": "valide",
"Champ": "00000007",
"Origine_contenus": "test blablablablablablabla",
"Date_crawl": "02/02/2023"
}
}
]
I send the request and I had an error message (Status:400 Bad request means that bad synthax):
{"documentation":"https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/error-handling.htm","errorcode":0,"message":"Bad Request"}
Does someone know where is my mistake ?
Sorry if it seems that my mistake is a stupid one, I'm completely a beginner in api call

SAP Business One Service Layer - Upload Attachment - Internal Error (-43)

I'm having an issue uploading an attachment into SAP B1 via the Service Layer. I am able to upload an attachment using the SAP client without issue. I'm using Postman to test sending the request before I embed this into a real application. I've gone over the documentation available in the SAP B1 Service Layer Guide (located here https://help.sap.com/doc/0d2533ad95ba4ad7a702e83570a21c32/9.3/en-US/Working_with_SAP_Business_One_Service_Layer.pdf) on page 106.
Here's what my HTTP request looks like... and it matches what the documentation expects.
POST /b1s/v1/Attachments2 HTTP/1.1
Host: 129.159.XXX.XXX:50000
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Cookie: B1SESSION=62bbdc3e-d634-11ec-8000-02001703771b; ROUTEID=.node3
Content-Length: 197
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="files"; filename="JSON-Tshirt-Master Product.txt"
Content-Type: text/plain
(data)
----WebKitFormBoundary7MA4YWxkTrZu0gW
Here's the error that I'm getting which doesn't make sense to me. I can't find anything on this error and I was wondering if anyone had seen something like this before?
{
"error": {
"code": -43,
"message": {
"lang": "en-us",
"value": "Internal error (-43) occurred"
}
}
}

How to send multipart/form-data for image binary with Python requests lib (with CRLF chars)?

I'm trying to upload a local image to the Medium /images endpoint (documented here).
Their example request looks like:
Host: api.medium.com
Authorization: Bearer 181d415f34379af07b2c11d144dfbe35d
Content-Type: multipart/form-data; boundary=FormBoundaryXYZ
Accept: application/json
Accept-Charset: utf-8
--FormBoundaryXYZ
Content-Disposition: form-data; name="image"; filename="filename.png"
Content-Type: image/png
IMAGE_DATA
--FormBoundaryXYZ--
The type of image data is never specified, but I'm assuming it's raw binary based on this very similar API call from Ancestry for uploading images.
Currently, I have:
headers['Content-Type'] = 'multipart/form-data; boundary=FormBoundaryXYZ'
imageData = '''--FormBoundaryXYZ
Content-Disposition: form-data; name="image"; filename="filename.jpg"
Content-Type: image/jpeg
0000000000000011111111111111111111111111
0000000000000011111111111111111111111111
0000000000000011111111111111111111111111
0000000000000000011111111111111111111111
0000000000000000000111111111111111111111
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000001000000000000000000
0000000000000000000100000000000000000000
0000000000000000010000000000000000000000
0000000000000000000000000000000000000000
0000000010000000000000000000000000000000
0000000000001100000000000000000000000000
0000000000000100000001000000000000000000
0000000000000000000001000000000000000010
0000000000000000001001111111110000000001
0000000000000000000000100110000000000000
0000000000000000000000000001110000000000
0000000000000000011110001111111101100000
0000000000000000111111111111111111111111
0000000001000001111111111111111111111111
0000000000000011111111111111111111111111
0000000100001011111111111111111111111111
0000001100000001111111111111111111111111
0000110000000000000000000000000000000000
0001000000000000000000000000000000000000
--FormBoundaryXYZ--'''
def post_image(imgData):
req = r.post(base_url+'/images', headers=headers, data=imgData)
res = req.json()
return res
print(json.dumps(post_image(imageData), indent=2))
When executed, I get the error response:
{
"errors": [
{
"message": "Expected CR Received 10",
"code": -1
}
]
}
The documentation mentions
All lines in the body must be terminated with \r\n.
and I know that the "10" in the response must be the "\n", so I'm missing the "\r". I've tried explicitly adding "\r\n" to the end of each line termination, but then I get an error like
{
"errors": [
{
"message": "Expected alphabetic character, received 10",
"code": -1
}
]
}
Or
{
"errors": [
{
"message": "stream ended unexpectedly",
"code": -1
}
]
}
depending on where I place the /r/n or remove it.
My question is: Is there a way to format this that I'm missing or overthinking? I'm hoping I'm just inexperienced in multipart/form-data encoding and I could be doing this programmatically instead.
Thanks! I'd be happy to add details if needed!
(As a side note: I got the image's binary data with the dcode.fr/binary-image tool.)

imgur API v3 upload image keep getting back status 1203: "Imgur is over capacity. Please try again."

This is the request I am posting
POST /3/image HTTP/1.1
Host: api.imgur.com
Authorization: Client-ID <My client ID>
Cache-Control: no-cache
----WebKitFormBoundaryE19zNvXGzXaLvS5C
Content-Disposition: form-data; name="image"
http://png1.findicons.com/files/icons/1580/devine_icons_part_2/128/home.png
----WebKitFormBoundaryE19zNvXGzXaLvS5C
However, the response I get is:
{
"data": {
"error": "Imgur is over capacity. Please try again.",
"request": "/3/image",
"method": "POST"
},
"success": false,
"status": 1203
}
I just want to use anonymous upload but the documentation is saying limit of 10MB right? anything I have done wrongly? what should I do to fix this error?
Imgur is frequently over capacity, so perhaps you can try again later. I doubt it's a problem on your end.

ErrorInvalidRequest while using post request in office365

using restClient, I am trying to add a new event.
url: https://outlook.office365.com/ews/odata/Me/Events
My json for the creation of an event is
{"IsAllDay":false,"Subject":"TEST","Start":"2015-02-20T07:32:39Z","End":"2015-02-20T08:32:39Z","Body":{"ContentType":"HTML","Content":"TEST JRA ? TU VOIS ?"}}
The response I get is
{
"error":
{
"code": "ErrorInvalidRequest",
"message": "Cannot read the request body."
}
}
What is wrong with my json and how do I solve this error ?
Make sure your Content-Type is "application/json".
I am able to make the request work. See below for sample request and response.
POST https://outlook.office365.com/api/v1.0/Me/Events HTTP/1.1
Authorization: <Snipped>
Content-Type: Application/Json
{
"IsAllDay":false,
"Subject":"TEST",
"Start":"2015-02-20T07:32:39Z",
"End":"2015-02-20T08:32:39Z",
"Body":{
"ContentType":"HTML",
"Content":"TEST JRA ? TU VOIS ?"
}
}