Can someone please help me with the Json Request to upload multiple documents in a envelope. I have pasted the request below.
The error that I get is
API call failed, status returned was: 400
Error description:
{ "errorCode": "NO_DOCUMENT_RECEIVED", "message": "The document element did not contain the encoded document, or there is a problem with the encoding. Bytes for document corresponding to documentId 1 not found in request. 'documentId=' possibly missing from Content-Disposition header."}
--BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"emailSubject" : "This is email subject",
"emailBlurb" : "This is email body",
"recipients" : {
"signers" : [ {
"routingOrder" : "1",
"name" : "name",
"email" : "valid email address",
"recipientId" : "1",
"tabs" : {
"signHereTabs" : [ {
"anchorTab" : {
"anchorString" : "SignHere",
"anchorXOffset" : "1",
"anchorYOffset" : "1",
"anchorIgnoreIfNotPresent" : "true",
"anchorUnits" : "inches"
}
} ]
}
} ]
},
"documents" : [ {
"name" : "document.pdf",
"documentId" : "1"
}, {
"name" : "document2.pdf",
"documentId" : "2"
} ],
"status" : "sent"
}
--BOUNDARY
Content-Disposition: form-data
Content-Type: multipart/mixed; boundary=BBB
--BBB
Content-Type: application/pdf
Content-Disposition: file; filename="document.pdf"; documentid="1"
[B#47df4d31
--BBB
Content-Type: application/pdf
Content-Disposition: file; filename="document2.pdf"; documentid="2"
[B#1544f0d4
--BBB--
--BOUNDARY--
Related
{
"version": 46,
"actions": [
{
"action" : "addCustomLineItem",
"name" : {
"en" : "Global India"
},
"quantity" : 1,
"money" : {
"currencyCode" : "INR",
"centAmount" : 4200
},
"slug" : "mySlug",
"taxCategory" : {
"typeId" : "tax-category",
"id" : "20f5a0ca-e3fd-48b6-8258-8dc8c75fe22a"
}
}
]
}
Above is my body request.
And we have stored above data in cartIdData variable. I am not getting response. showing it does not contain valid json format.
this.cartIdData = {
version:this.cartversion,
productId:this.productID,
currency:this.currencycode,
price:this.priceparseInt,
cartaction:action,
india:this.name,
slugname:this.slugname
};
I need to send an Arabic message with postman. I recieve the text as ??????? instead of arabic characters.
here's the body of my request in postman :
{
"authentication": {
"username": "myusernam",
"password": "mypassword"
},
"messages": {
"sender": "Mysender",
"text": "رأيكم يهمنا. المرجو تنقيط جودة استفدتم منها عبر الرابط التالي: ht
"recipients": [
{
"gsm": "21260000000"
}
]
}
}
and here are the headers that I have included:
Content-Type : application/json; charset = utf-8
Accept : application/json; charset = utf-8
use this
value = System.Uri.UnescapeDataString(value);
I am just wondering why ES uses that header if the body of the request is not a json but text with multiple lines, each of which is a json. For example:
{ "create" : { "_index" : "movies", "_type" : "movie", "_id" : "135569" } }
{ "id": "135569", "title" : "Star Trek Beyond", "year":2016 , "genre":["Action", "Adventure", "Sci-Fi"] }
{ "create" : { "_index" : "movies", "_type" : "movie", "_id" : "122886" } }
{ "id": "122886", "title" : "Star Wars: Episode VII - The Force Awakens", "year":2015 , "genre":["Action", "Adventure", "Fantasy", "Sci-Fi", "IMAX"] }
{ "create" : { "_index" : "movies", "_type" : "movie", "_id" : "109487" } }
{ "id": "109487", "title" : "Interstellar", "year":2014 , "genre":["Sci-Fi", "IMAX"] }
{ "create" : { "_index" : "movies", "_type" : "movie", "_id" : "58559" } }
{ "id": "58559", "title" : "Dark Knight, The", "year":2008 , "genre":["Action", "Crime", "Drama", "IMAX"] }
{ "create" : { "_index" : "movies", "_type" : "movie", "_id" : "1924" } }
{ "id": "1924", "title" : "Plan 9 from Outer Space", "year":1959 , "genre":["Horror", "Sci-Fi"] }
This would be a valid request despite not being a well-formatted json. Is it common in RESTful interfaces to define something as application/json even if it's not? You can't even send it from Postman, only from cURL, which does not validate the body syntax.
Technically, when calling the _bulk endpoint, the content type header should be application/x-ndjson
and not application/json as stated in their docs
the final line of data must end with a newline character \n. Each newline character may be preceded by a carriage return \r. When sending requests to this endpoint the Content-Type header should be set to application/x-ndjson.
The reason it is not a JSON array is because when the coordinating node receives the bulk request, it can split it in several chunks simply by looking at how many lines (i.e. new line characters) there are and send each chunk to a different node for processing. If the content was JSON, the coordinating node would have to parse it all and for several megabyte bulk queries, it would have a negative impact on performance.
NDJSON is a convenient format for storing or streaming structured data that may be processed one record at a time.
This follows on from Extracting selected properties from a nested JSON object with jq which lets the OP there get rid of a load of unwanted properties from a nested object.
I've got the same problem but instead of an array starting [, just have a stream of JSON objects, each like this:
{
"localHostName" : "rest-2-17ve6",
"port" : "80",
"requestHeaders" : {
"x-forwarded-port" : "443",
"x-forwarded-host" : "dummy.com",
"content-length" : "15959431",
"accept" : "*/*",
"x-forwarded-for" : "10.1.9.11",
"authorization" : "hash is present",
"expect" : "100-continue",
"forwarded" : "for=10.5.9.1;host=dummy.com;proto=https",
"content-type" : "application/json",
"host" : "dummy.com",
"x-forwarded-proto" : "https",
"user-agent" : "curl/7.51.0"
},
"uri" : "/2/data/saveList",
"protocol" : "HTTP/1.1",
"threadName" : "http-nio-8080-exec-10",
"requestBytes" : 15959431,
"applicationDuration" : 44135,
"responseStatus" : "200",
"remoteIpAddress" : "10.1.10.1",
"responseHeaders" : {
"X-XSS-Protection" : "1; mode=block",
"Content-Type" : "application/json;charset=UTF-8",
"X-Content-Type-Options" : "nosniff",
"Cache-Control" : "no-cache, no-store, max-age=0, must-revalidate",
"Date" : "Wed, 20 Jun 2018 15:53:27 GMT",
"Transfer-Encoding" : "chunked",
"Vary" : "Accept-Encoding",
"X-Frame-Options" : "DENY",
"Expires" : "0",
"Pragma" : "no-cache"
},
"isoDateTime" : "2018-06-20T15:52:42.466913985Z",
"method" : "POST",
"username" : "rd7y1",
"localIpAddress" : "10.129.9.238",
"responseBytes" : 2,
"requestContentExcerpt" : "blah",
"totalDuration" : 44869,
"responseContentExcerpt" : " [] "
}
I want to filter the stream on the command line so I only get:
{
"isoDateTime" : "2018-06-20T15:52:42.466913985Z",
"method" : "POST",
"username" : "rd7y1",
"requestHeaders.user-agent" : "Rcurl"
}
I tried cat /logs/json.log | jq -cC 'map(requestHeaders|={user-agent})' but I'm getting a syntax error.
Since jq is stream-oriented, you would just use select(...) rather than map(select(...))
It looks like you intend to use .requestHeaders."user-agent" in the criterion for selection.
It's generally recommended to avoid using cat when possible.
According to your stated requirements, you should drop the -c command-line option.
Since "Rcurl" does not appear in your sample input, I'll use the string that does appear.
So in your case, you'd end up with something like:
< /logs/json.log jq '
select(.requestHeaders."user-agent" == "curl/7.51.0")
| {isoDateTime, method, username,
"requestHeaders.user-agent": .requestHeaders."user-agent"}'
I was hoping someone could explain what the POST request (with parameters) accomplishes. When I run the following command, provided by Alamofire's documentation, this is what is produced:
Code
let url = "https://httpbin.org/post"
let parameters: Parameters = [
"foo": "bar",
"baz": ["a", 1],
"qux": [
"x": 1,
"y": 2,
"z": 3
]
]
Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseJSON { response in
if((response.result.value) != nil) {
let jsonVar: JSON = JSON(response.result.value!)
print(jsonVar)
}
}
Result
{
"files" : {
},
"origin" : "192.104.181.247",
"data" : "{\"baz\":[\"a\",1],\"qux\" {\"y\":2,\"x\":1,\"z\":3},\"foo\":\"bar\"}",
"headers" : {
"Accept" : "*\/*",
"Accept-Encoding" : "gzip;q=1.0, compress;q=0.5",
"Content-Type" : "application\/json",
"Host" : "httpbin.org",
"Content-Length" : "53",
"User-Agent" : "HTTPRequest\/1.0 (com.dexstrum.HTTPRequest; build:1; iOS 10.2.0) Alamofire\/4.3.0",
"Accept-Language" : "en;q=1.0"
},
"json" : {
"baz" : [
"a",
1
],
"foo" : "bar",
"qux" : {
"x" : 1,
"y" : 2,
"z" : 3
}
},
"form" : {
},
"args" : {
},
"url" : "https:\/\/httpbin.org\/post"
}
What exactly is occurring with the parameters and the POST request?
The url you are hitting it allows a post request. You can get json response by get or post method. Usually you fetch data by get method and send data by post method. When sending data with post request it needs some parameter to satisfy its requirement , usually its predefined.
SO you are sending a post request here with alamofire and along with some parameter which satisfy its requirements. Here you are encoding the parameter as JSONEncoding.default which means it sends the parameter data encoded as json finally you get the response as json coz you declared .responseJSON . Hope that helps.