I am trying to use the Quickbase API (see reference below) with a POST. I am having trouble forming it; specifically, I am clueless as to how to format the header (headers=""). I think the XML Payload is correct, but who knows. Thanks for your help!
Quickbase API reference:
Example XML Request
POST /db/6c5xatxy HTTP/1.0
Content-Type: application/xml
Content-Length: 88
QUICKBASE-ACTION: API_GetRecordInfo
<qdbapi>
<rid>4</rid>
<ticket>1_6c6482m9_j36_c7mdvh9cmmtn9c8qtr5qchvw33v</ticket>
</qdbapi>
My code:
<fx:Declarations>
<s:HTTPService id="serviceQBPost" method="POST"
url="https://www.quickbase.com/db/beu45unrw"
headers="Content-Type: application/xml Content-Length: 88 QUICKBASEACTION:API_GetRecordInfo"
result="serviceQBPost_resultHandler(event)"
fault="serviceQBPost_faultHandler(event)">
<s:request xmlns="">
<qdbapi>
<rid>4</rid>
<ticket>1_6c6482m9_j36_c7mdvh9cmmtn9c8qtr5qchvw33v</ticket>
</qdbapi>
</s:request>
</s:HTTPService>
</fx:Declarations>
The easier is going to be to form your GET requests in a normal browser, then move that to Flex after it works. try https://www.quickbase.com/db/?act=APIGetRecordInfo&rid=1&username=&password=
I wouldn't worry about formatting the XML. Use the REST-style GET, pass the username+password with each request, and go. It's easier.
Related
I'm developing aplication which sends thousands of http post requests. I want to record all responses and use them as stubs with help of Fiddler`.
For example (lets assume product price = productid for simplicity):
send request, body<productId>1</productId>
get real response, body <productprice>1</productprice>
save response (headers+body) form previous step in local storage,for
example in some dictionary [1,"HTTP/1.1 200 OK
<productprice>1</productprice>"]. (Since we stored this response,
next requests matching pattern body contains
<productId>1</productId>should be responded from our local storage
)
send request, body <productId>1</productId>
load response from local storage and return HTTP/1.1 200 OK
<productprice>1</productprice>
send request, body <productId>2</productId>
get real response, body <productprice>5</productprice>
save response (headers+body) form previous step in local storage,for
example in some dictionary [1,"HTTP/1.1 200 OK
<productprice>1</productprice>"],[2,"HTTP/1.1 200 OK
<productprice>2</productprice>"]
...
How to configure Fiddler for it?
Details:
I have already captured 1000 real POST requests and i want to debug my application with help of them.
Each request / response is unique and in general looks like:
request
POST https://myurl HTTP/1.1
Authorization: Bearer xxx
Content-Type: application/soap+xml; charset=utf-8; action="GetList"
Host: myurl.net
Content-Length: 358
Expect: 100-continue
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<catalogRequest xmlns="https://myurl">
<id xmlns="">1</id>
</catalogRequest>
</s:Body>
</s:Envelope>
response
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="https://myurl">
<env:Body>
<ns1:catalogResponse>
<result>
<id>1</id>
<name>some text</name>
<price>109.99</price>
... big xml ...
<status>1</status>
</result>
</ns1:catalogResponse>
</env:Body>
</env:Envelope>
I tried Autoresponder, but when i dragged captured sessions to the Autoresponder they were converted to rules like: METHOD:POST EXACT: - this rule doesn't use POST body. I can't manually change 1000 rules to use URLWithBody rule
I think it is possible to create Fiddler script, but i don't know how to store captured requests/responses for this script to use them as mapping.
After small research i found a way to record responses and use them as stubs in future. To acheive that i suggest to use fiddler scripts. Here example of scripts in pseudocode
For BeforeRequest:
var body = session.requestBodyBytes;
var id = GetIdFromBody(body);// code for getting id from request body
session.Reply = id;
For AfterResponse:
var body = session.GetRequestBodyAsString();
var id = GetIdFromRespBody(body);// code for getting id from response body
session.SaveResponse(id);
I was able to find a lot of information about multipart/form-data but not much about multipart/related. In terms of the protocol / request format, can someone explain the differences between these two http specifications when it comes to file uploading?
multipart/form-data is used to upload files of MIME-compatible representation, such as pictures and video files, and related metadata a single POST request. That's what happens when you fill in a form online with attached pictures and then press the "Submit" button.
multipart/related is used for compound documents and you would need to combine the separate body parts to provide the full meaning of the message. One use case would be submitting some Base64-encoded images together with the associated metadata.
One POST request sample is (https://cloud.google.com/storage/docs/json_api/v1/how-tos/multipart-upload):
POST https://www.googleapis.com/upload/storage/v1/b/myBucket/o?uploadType=multipart HTTP/1.1
Authorization: Bearer [YOUR_AUTH_TOKEN]
Content-Type: multipart/related; boundary=foo_bar_baz
Content-Length: [NUMBER_OF_BYTES_IN_ENTIRE_REQUEST_BODY]
--foo_bar_baz
Content-Type: application/json; charset=UTF-8
{
"name": "myObject"
}
--foo_bar_baz
Content-Type: image/jpeg
[JPEG_DATA]
--foo_bar_baz--
You can find more details at https://msdn.microsoft.com/en-us/library/ms527355(v=exchg.10).aspx
What's wrong with the format of this http header that uses multipart/form-data? When you run the above code nothing gets posted, httpbin.org displays nothing in the forms section. I've checked it against other multipart/form-data packets and they're near similar.
You are missing some needed line breaks between the MIME parts, for starters:
$parameters = "
--$boundary
Content-Disposition: form-data; name=`"name`"
upload.txt
--$boundary
Content-Disposition: form-data; name=`"file`"; filename=`"input.txt`"
Content-Type: text/plain
--$boundary--"
And you are not actually including any content for input.txt in the second MIME part at all. Is that what you really want - to post a blank file?
I've checked it against other multipart/form-data packets and they're near similar.
That implies that they are different, so you need to pay attention to those differences.
I use biz2006 + rosettaNet as our EDI solution. Now I meet a issue that, when a partner send pip to us, the content(base64 encoded) could not been converted to XML plain text.
Here're content of the pip we received.
MIME-Version: 1.0
Content-Type: application/xml; charset="UTF-8"; RNSubType=service-header`
Content-Transfer-Encoding: base64
Content-ID: 3e10e7db96b84cafbee51e66e020729f
Content-Description: body
Content-Disposition: attachment; filename="Attachment1"
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgU2VydmljZUhl
...==
I find a working format as below
Content-Transfer-Encoding: binary
<?xml version="1.0" encoding="UTF-8"?>
Anyone could tell we how to solve the issue?
Any suggestion is appreciated.
Dont know if you fixed this for yourself but I think this may help your problems:
http://biztalkmessages.vansplunteren.net/articles/dealing-with-base64/
Lots of other nice Biztalk hints and tips on there too!
Source: (Randal van Splunteren)
I would like to create a HTTP response, using multipart/mixed, but I'm not sure which browsers support it; and if it's as convenient as it sounds, from the client's point of view.
To be honest, I do not need specifically that content type. I just want to transmit more than one file in the same response; maybe there's another content-type more used.
I've tested it, with a home-made server and a simple response. Not sure if the response is well-formed because no browser understands it 100% OK. But here are the results:
Firefox 67.0.1 (64-bit): Renders only the last part, others are ignored.
IE 11.503: Saves all the content in a single file (including the boundaries), nothing is rendered.
Chrome May 2019: Saves all the content in a single file, nothing is rendered.
Safari 4: Saves all the content in a single file, nothing is rendered.
Opera 10.10: Something weird. Starts rendering the first part as plain/text, and then clears everything. The loading progress bar hangs on 31%.
Here's the complete response, if anyone finds any error, please tell me and I'll try again:
HTTP/1.1 200 OK
Date: Tue, 01 Dec 2009 23:27:30 GMT
Vary: Accept-Encoding,User-Agent
Content-Length: 681
Content-Type: Multipart/mixed; boundary="sample_boundary";
Multipart not supported :(
--sample_boundary
Content-Type: text/css; charset=utf-8
Content-Location: http://localhost:2080/file.css
body
{
background-color: yellow;
}
--sample_boundary
Content-Type: application/x-javascript; charset=utf-8
Content-Location: http://localhost:2080/file.js
alert("Hello from a javascript!!!");
--sample_boundary
Content-Type: text/html; charset=utf-8
Content-Base: http://localhost:2080/
<html>
<head>
<link rel="stylesheet" href="http://localhost:2080/file.css">
</head>
<body>
Hello from a html
<script type="text/javascript" src="http://localhost:2080/file.js"></script>
</body>
</html>
--sample_boundary--
In my experience, multipart responses work in Firefox but not in Internet Explorer. This was 2 years ago, using the browsers of the time.
I have had HTTP multipart responses working for a stream of JPEG images. For example, Axis IP cameras use for their motion JPEG stream for Firefox. For Internet explorer, Axis require the use of a plugin.
If Firefox-only support meets your requirements, then I recommend setting the content-length header in each part of the multi-part response. It might help to make the boundary string identical in the original HTTP header and the multi-part response (the '--' is missing in the HTTP header).
Two ideas:
Formatting: I think "multipart" should be in lower case, and I don't think a semicolon is expected at the end of the Content-type header (although it's doubtful that it will make a difference, it's possible that it might).
Have you tried replace mode? Just use: Content-type: multipart/x-mixed-replace -- everything else should stay the same.
Multi part it yourself
(A good option)
A multipart response can be made manually!
So one can write a no multipart response! Let's say in chunked mode! There it make sense!
So you are streaming the data!
Send all as blunt text!
Make your own separators! Between each part!
In the browser! Extract and parse the data! Split to get each part separately!
And parse each appart! Depending on what type of data it hold!
So if a part is json! You parse it as so!
Quick illustration! Let say we want to send a csv file! Or some other type of file! Along that we want to send too a json object!
And that by streaming it by chunk
Here a code that illustrate that in express:
const data = {
initCapital: fileState.mappingObj.initialCapital
};
res.write(JSON.stringify(data, undefined, 0));
res.write('>>>>'); // parts separator
fileState.readStream.pipe(res); // continue streaming the file (chunk by chunk)
And in the client
export function parseBackTestFetchedData(data: string) {
const [_data, csvData] = data.split('>>>>');
return {
data: JSON.parse(_data),
backTestStatesData: parseCsv(csvData)
};
}
That way! it doesn't matter who the client is!