I'm using neo4jclient. When I try to create/update an node, special chars like äöü are replaced with �.
Do I have to set a specific http header like content-type, content-encoding? If yes, what kind of header and what is the value of this header?
Thanks.
EDIT:
This is how the request looks like:
POST http://...........:7474/db/data/batch HTTP/1.1
Accept: application/json;stream=true
User-Agent: RestSharp 103.1.0.0
Content-Type: application/json
Host: ............:7474
Content-Length: 267
Accept-Encoding: gzip, deflate
[
{
"method": "POST",
"to": "/node",
"body": {
"Name": "äöü",
"State": "Active",
"Id": 0,
"CreateDate": "2012-07-12T18:48:45.3343526+02:00",
"ChangeDate": "0001-01-01T00:00:00+00:00"
},
"id": 0
}
]
Or is it bug in the batch execution? If yes, I'll need the fix very quick:)
Now it works
After analyzing the messages.log we found out, that the file.encoding wasn't utf-8.
--> DEBUG [neo4j.diagnostics]: file.encoding = Cp1252
So we set in the neo4j-wrapper.conf file this property:
wrapper.java.additional.3=-Dfile.encoding=UTF-8
Now it works!!! :)
Thanks to my brother! Always good to know a Java developer. :)
There are tests for this in the codebase, so it should be handled correctly, see https://github.com/neo4j/community/blob/master/server/src/functionaltest/java/org/neo4j/server/rest/BatchOperationFunctionalTest.java#L322 . However, there might be encoding problems in the client?
Related
We are making a POST to
sandbox-quickbooks.api.intuit.com/v3/company/{realm_id}/attachable
with header:
Content-Type: multipart/form-data; boundary="--fdlkjflksd--"
and body:
--fdlkjflksd--
Content-Disposition: form-data; name="file_metadata_01"; filename="attachment.json"
Content-Type: application/json; charset=UTF-8
Content-Transfer-Encoding: 8bit
{"AttachableRef": [{"EntityRef": {"type": "Purchase", "value": "144"}}], "FileName": "one_pixel.jpeg", "ContentType": "image/jpeg"}
--fdlkjflksd--
Content-Disposition: form-data; name="file_content_01"; filename="one_pixel.jpeg"
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
/9j/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAEBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAAA//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAD8AN//Z
--fdlkjflksd--
and we are getting in response:
{"Fault":{"Error":[{"Message":"Unsupported Operation","Detail":"Operation Cannot consume content type is not supported.","code":"500"}],"type":"ValidationFault"},"time":"2020-03-07T03:00:51.600-08:00"}
we followed this example
The /attachable endpoint is for linking EXISTING attachments to an object, and the Content-Type is:
application/json
Docs are here: https://developer.intuit.com/app/developer/qbo/docs/develop/tutorials/attach-images-and-notes#attaching-a-note-to-an-object
The /upload endpoint is for uploading NEW attachments, and the Content-Type is:
multipart/form-data
Docs: https://developer.intuit.com/app/developer/qbo/docs/develop/tutorials/attach-images-and-notes#uploading-files-to-the-attachment-list
It looks like you've mixed then up - it looks like you're trying to upload a new file to the existing file endpoint.
I'm having several calls that should be launched in parallel in a single batch request. This requests are function import call and two read requests. sapui5 version is 1.38.17 and odata model v2 used in this issue.
Here is request calls.
var oContext = this.getView().getBindingContext();
var oModel = this.getModel();
oModel.setDeferredGroups(["CSC"]);
oModel.setChangeGroups({
"FunctionImport1": {
groupId: "CSC",
changeSetId: "CSC1",
single: false
},
"ToRead1Set": {
groupId: "CSC",
changeSetId: "CSC1",
single: false
},
"ToRead2Set": {
groupId: "CSC",
changeSetId: "CSC1",
single: false
}
});
oModel.callFunction("/FunctionImport1", {
method: "POST",
groupId: "CSC",
changeSetId: "CSC1",
urlParameters: {
"Arg1": oContext.getObject("GUID"),
"Arg2": "",
"Arg3": ""
}
});
var sGUID1= oContext.getObject("ToRead1/GUID");
var sGUID2 = oContext.getObject("ToRead2/GUID");
oModel.read(oModel.createKey("/ToRead1Set", { GUID: sGUID2 }), {
groupId: "CSC",
changeSetId: "CSC1"
});
oModel.read(oModel.createKey("/ToRead2Set", { GUID: sGUID2 }), {
groupId: "CSC",
changeSetId: "CSC1"
});
oModel.submitChanges({
groupId: "CSC"
});
Initially there was only callFunction and read operations calls.
After I noticed that requests are not in the same batch I added setDeferredGroup call, but that didn't helped. After that I tried to add setChangesGroups that didn't worked either.
Here is what sapui5 odata model is sending.
--batch_e90b-96a1-4abd
Content-Type: multipart/mixed; boundary=changeset_f22c-3b40-d8af
--changeset_f22c-3b40-d8af
Content-Type: application/http
Content-Transfer-Encoding: binary
POST FunctionImport1?Arg1='123123123123'&Arg2=''&Arg3='' HTTP/1.1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: prD6hap9bHc_pk8kt1Q7pg==
Content-Type: application/json
--changeset_f22c-3b40-d8af--
--batch_e90b-96a1-4abd
Content-Type: application/http
Content-Transfer-Encoding: binary
GET ToRead1Set('') HTTP/1.1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: prD6hap9bHc_pk8kt1Q7pg==
--batch_e90b-96a1-4abd
Content-Type: application/http
Content-Transfer-Encoding: binary
GET ToRead2Set('') HTTP/1.1
sap-contextid-accept: header
Accept: application/json
Accept-Language: en
DataServiceVersion: 2.0
MaxDataServiceVersion: 2.0
x-csrf-token: prD6hap9bHc_pk8kt1Q7pg==
--batch_e90b-96a1-4abd--
Notice that batch ids and changesSet ids are the same, so, logically it is the same batch for every request, but, in practice backend and SAP Netweaver Gateway Service thinks that it is a three separate batch requests.
So, the questions are
1. Is it SAPUI5 bug or Gateway bug, if it is a bug at all?
2. How can I put this requests into single batch requests without this psychical division of requests with --batch lines.
I'm beginning to think about catching the formed payload and manually cut --batch separators between requests for this particular case, because can't find another way to do that.
I've got the initial half of an OAuth flow working with the SurveyMonkey API, but when I try to exchange the short-lived authorization code for a long-lived OAuth access token, I get an HTTP 400 response. This is step 3 of the SurveyMonkey OAuth Guide.
Here's a scrubbed version of the full exchange:
POST /oauth/token?api_key=<removed> HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate, compress
Content-Length: 338
Content-Type: application/json; charset=utf-8
Host: api.surveymonkey.net
User-Agent: HTTPie/0.7.2
{
"client_id": "<removed>",
"client_secret": "<removed>",
"code": "dKkIJYnimBli3TMHoTdHoT-zkzkUFzfHeaWJJyPVmrYG35R5Q-jLLU-Y7Fg3BR0n3tVTQ6sAmDnwVxHXSjZVdiYTJ7u7SWbLCKgQa061bKJYXSpRhTsEL0v5GMWcMEBC2vje5UjRHp3SScFQEwIIjHKZH5raC5RQJJh.JYWEOqw8Iy-2Ds7km1zYaHGGlxqu",
"grant_type": "authorization_code",
"redirect_uri": "https://app.hubspotqa.com"
}
HTTP/1.1 400 Bad Request
Cache-Control: no-store
Connection: keep-alive
Content-Length: 96
Content-Type: application/json; charset=UTF-8
Date: Fri, 24 Jan 2014 00:05:53 GMT
SM-Request-ID: 41264d11-b93d-4f8b-ad1a-c656ccfa268b
Server: nginx
{
"error": "invalid_request",
"error_description": "Invalid POST body or Content-Type received."
}
I'm able to reproduce the exact same error using other HTTP clients as well, but I have no trouble manually getting an access token using the SurveyMonkey API console. What am I doing wrong?
Side question: the OAuth guide says that step 3 accepts a redirect_uri but the example Python guide uses redirect_url. Which is the correct parameter? Can I omit it entirely? My server certainly does not care about getting redirected anywhere.
As it turns out, the required Content-Type for this POST is form encoding – application/x-www-form-urlencoded, not JSON.
Note that the documentation does not actually say that anywhere; it's implied by the example usage of the Python requests library.
Answered :
The X-Upload-Content-Length value had a space in it.
Question :
I want to use the Youtube API to upload videos from a desktop application, in C++. I implemented the Resumable Upload, everything worked on Friday 19/07 in the afternoon, I could upload a couple of small videos, and since then I always get an error when using my app : "503 : Service Unavailable".
I found several threads treating this topic, it seems there were two solutions :
Retry the request several times in a row
Wait, it somehow works again after a while
Doing the same request again and again didn't solve it for me (I tried to do the request 5 times in a row, maybe I should do more requests ? How many ?). Here is a sample request and the response I get :
Request :
POST https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet HTTP/1.1
Accept: */*
Accept-Language: xx
Authorization: Bearer MY_ACCESS_KEY
X-GData-Key: key=MY_DEV_KEY
Content-Type: application/json
X-Upload-Content-Type: video/avi
X-Upload-Content-Length: 302 080
User-Agent: SOME_PRIVATE_STUFF
Host: www.googleapis.com
Content-Length: 167
Connection: Keep-Alive
Cache-Control: no-cache
{
"snippet": {
"title": "My video title",
"description": "This is a description of my video",
"tags": ["cool", "video", "more keywords"],
"categoryId": 22
}
}
Response :
HTTP/1.1 503 Service Unavailable
Date: Fri, 26 Jul 2013 16:33:27 GMT
Server: HTTP Upload Server Built on Jul 21 2013 19:20:38 (1374459638)
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Thanks for any help, I really don't know what to do right now.
I'm working with the D2L API,and am having difficulty with some POST requests.
Doing a version check (POST) using the JSON object:
[{ "ProductCode": "lp", "Version": "1.0" }]
returns correctly, providing me a valid JSON object in response, that being said I'm confident that my code to issue the call is working correctly.
When I issue a POST to create a post in a forum, however, I get a 404 in response. The JSON object I'm sending for this call is:
[
{
"ParentPostId": null,
"Subject": "API Posted",
"Message": {
"Text": "This message has been posted by the API",
"HTML": "This message has been posted by the API"
},
"IsAnonymous": false
}
]
And the URL submitted to is /d2l/api/le/{ver}/{orgId}/discussions/forums/{forumId}/topics/{topicId}/posts/
I've verified that ver/orgId/forumId/topicId are all valid using a GET of a post in the same forum and topic. I've also tried quoting the values for ParentPostId and IsAnonymous both separately and in unison.
Try removing the square brackets from the JSON.
An example of a successful request and response follows:
REQUEST
POST https://valence.desire2learn.com/d2l/api/le/1.0/7664/discussions/forums/203/topics/508/posts/?x_b=TwULqrltMXvTE8utuLCN5O&x_a=L2Hd9WvDTcyiyu5n2AEgpg&x_d=nF61tBeuzd0EPTW7nm8iGc4MB7NeJZaNM2VlzHp0bwU&x_c=I3i_k2aANTIf2X6aFsiOdvlElSR_avvOYnA2ibcWabA&x_t=1343335429 HTTP/1.1
Accept-Encoding: gzip,deflate
Accept: application/json
Content-Type: application/json
{ "ParentPostId": null, "Subject": "API Posted", "Message": { "Content": "This message has been posted by the API", "Type": "HTML" }, "IsAnonymous": false }
RESPONSE
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Length: 369
Content-Type: application/json; charset=UTF-8
Expires: -1
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Date: Thu, 26 Jul 2012 20:43:58 GMT
{"ForumId":203,"PostId":574,"TopicId":508,"PostingUserId":3667,"ThreadId":205,"ParentPostId":null,"Message":{"Text":"","Html":"This message has been posted by the API"},"Subject":"API Posted","DatePosted":"2012-07-26T20:43:58.920Z","IsAnonymous":false,"RequiresApproval":false,"IsDeleted":false,"LastEditDate":null,"LastEditedBy":null,"CanRate":false,"ReplyPostIds":[]}
Looking at the documentation for that route at http://docs.valence.desire2learn.com/res/discuss.html#post--d2l-api-le-(D2LVERSION-version)-(D2LID-orgUnitId)-discussions-forums-(D2LID-forumId)-topics-(D2LID-topicId)-posts-, it looks like the required data structure uses a RichTextInput not a RichText for Message.
Try changing your Message field to:
{
"Content": "This message has been posted by the API",
"Type": "Text"
}