I'm doing a simple POST that returns the below. I'm expecting a .txt.gz file. I need to know how to retrieve the attachment. I've tried creating a buffer, delimiting, and splitting before writing the file, but it always comes back as corrupt.
The request library explains how to consume a PUT request for an attachment, but not how to consume a response back.
Can anyone help? Been at this for a week now.
JSON.stringify(res)
{
"statusCode": 200,
"body": {
"type": "Buffer",
"data": [
13,
10,
45,
45(..truncated)
]
},
"headers": {
"set-cookie": [
"JSESSIONIDSSO=982EF51351B9497045DB6AB5A2D50DBF; Path=/; Secure; HttpOnly",
"JSESSIONID=995EF8A4A893860159CE463582E4CDDD; Path=/logcollectionservice; Secure; HttpOnly",
"SoapSession.id=-2851099334472488788"
],
"x-frame-options": "SAMEORIGIN",
"strict-transport-security": "max-age=31536000; includeSubdomains",
"content-type": "multipart/related; type=\"text/xml\"; start=\"<852C508C64251E692C9217DFA4EB7433>\"; boundary=\"----=_Part_109_17473961.1526352793275\"",
"transfer-encoding": "chunked",
"date": "Tue, 15 May 2018 02:53:13 GMT",
"connection": "close",
"server": ""
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "50.22.22.22:8443",
"port": "8443",
"hostname": "50.22.22.22",
"hash": null,
"search": null,
"query": null,
"pathname": "/logcollectionservice/services/DimeGetFileService",
"path": "/logcollectionservice/services/DimeGetFileService",
"href": "https://50.22.22.22:8443/logcollectionservice/services/DimeGetFileService"
},
"method": "POST",
"headers": {
"Authorization": "Basic YWRt123123123123123123",
"SOAPAction": "http://schemas.cisco.com/ast/soap/action/#LogCollectionPort#GetOneFile",
"content-length": 467
}
}
}
res.body
------=_Part_183_12814895.1526363698144
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <5DDAB109C3B14685FF6B0EA83D2CF8E4>
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>
<ns1:GetOneFileResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://schemas.cisco.com/ast/soap/"><DataHandler
href="cid:36F92AA211EE04B422D4B07AB07D841A" xsi:type="ns2:DataHandler"
xmlns:ns2="DimeGetFileService"/></ns1:GetOneFileResponse>
</soapenv:Body></soapenv:Envelope>
------=_Part_183_12814895.1526363698144
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-Id: <36F92AA211EE04B422D4B07AB07D841A>
����o�:���W��U����<��퐖.�I��8!h�0�l��?~���m�z��;'����>��oL���'Ϗ��3
'�tSV�EO�8zÂ���[a0����.��`�4wbO�q��FI���:�n܍>��e-
��!^#"�U5��;��^����U[V���s˽��q_��̣
����{gm����r��
���c��㬌Pf]Z�����cs���#ߵ� (truncated)
------=_Part_183_12814895.1526363698144--
Related
We created a logic app standard that uses a service bus api connection. When looking in the tab "Connections" it says that the connection is in the "Connected" status.
The problem is that the trigger of the workflows fails and the Outputs json is the following:
{
"statusCode": 401,
"headers": {
"Cache-Control": "no-store, no-cache",
"Pragma": "no-cache",
"x-ms-request-id": "xxxx",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
"Timing-Allow-Origin": "*",
"x-ms-apihub-cached-response": "true",
"x-ms-apihub-obo": "true",
"Date": "Wed, 20 Jul 2022 15:21:08 GMT",
"Content-Length": "287",
"Content-Type": "application/json",
"Expires": "-1"
},
"body": {
"status": 401,
"message": "Key 'token' not found in connection profile.\r\nclientRequestId: 0b492f59-bca5-4901-8132-b0ce10416d25",
"error": {
"message": "Key 'token' not found in connection profile."
},
"source": "servicebus-xxx.azurewebsites.net"
}
}
What can possibly be the issue here?
Can this possibly be due to permission restrictions?
Hoping some here can help me.
I am trying to post an image to my API via HTTP Post. When I post using the following code:
--TestLine
Content-Disposition: form-data; name="Description"
test.txt
--TestLine
Content-Disposition: form-data; name="ExternalDocumentType"
ATTACH_DD
--TestLine
Content-Disposition: form-data; name="Filename"
test.txt
--TestLine
Content-Disposition: form-data; name="FormattedAccount"
002.2020.00199659.001
--TestLine
Content-Disposition: form-data; name="ModuleReference"
DD
--TestLine
Content-Disposition: form-data; name="FileUpload";filename=test.txt
Content-Type: text/plain
test upload
--TestLine--
it works for text files and image files BUT my images files are corrupted on the other end and cannot be opened.
I then read the following":
https://willpagenz.wordpress.com/2019/12/20/using-the-http-action-to-post-multipart-form-data-in-pow...
and tried coding it to that way:
{
"content-type": "multipart/form-data",
"multipart": [
{
"body": {
"$content": "test.txt"
},
"headers": {
"Content-Disposition": "form-data; name=\"Description\""
}
},
{
"body": {
"$content": "ATTACH_DD"
},
"headers": {
"Content-Disposition": "form-data; name=\"ExternalDocumentType\""
}
},
{
"body": {
"$content": "test.txt"
},
"headers": {
"Content-Disposition": "form-data; name=\"Filename\""
}
},
{
"body": {
"$content": "002.2020.00199662.001"
},
"headers": {
"Content-Disposition": "form-data; name=\"FormattedAccount\""
}
},
{
"body": {
"$content": "DD"
},
"headers": {
"Content-Disposition": "form-data; name=\"ModuleReference\""
}
},
{
"body": {
"$content": "test upload",
"$content-type": "text/plain"
},
"headers": {
"Content-Disposition": "form-data; name=\"FileUpload\";filename=\"test.txt\""
}
}
]
}
but now I get forbidden and it can't even post through to my API
<center><h1>403 Forbidden</h1></center>
<hr><center>Microsoft-Azure-Application-Gateway/v2</center>
This is time sensitive. Does anyone have an answer.
Thanks
I'm using NodeJS to upload panoramic images.
When I make #2 informed in the Google documentation, I get the following return:
Request
{
"url": "UPLOAD_URL",
"body": "/PATH_TO_PANO/pano.jpg",
"method": "POST",
"headers": {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "image/jpeg"
}
}
Response
{
"statusCode": 200,
"body": "",
"headers": {
"x-guploader-uploadid": "AEnB2UoJt4gvmmU6gXZvWDRu4b0DUCeT5vuPKLGcZqM4Tzo9HssCLoloTgAACRmxmP0U5DDYvHXpThCjRslW80bEKLZjUjJB3QNZ5w- j0jd8jdtVnH8X0c",
"content-length": "0",
"date": "Tue, 26 Sep 2017 21:05:17 GMT",
"server": "UploadServer",
"content-type": "text/html; charset=UTF-8",
"alt-svc": "quic=\":443\"; ma=2592000; v=\"39,38,37,35\"",
"connection": "close"
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "streetviewpublish.googleapis.com",
"port": 443,
"hostname": "streetviewpublish.googleapis.com",
"hash": null,
"search": null,
"query": null,
"pathname": "/media/user/USER_ID/photo/PHOTO_ID",
"path": "/media/user/USER_ID/photo/PHOTO_ID",
"href": "https://streetviewpublish.googleapis.com/media/user/USER_ID/photo/PHOTO_ID"
},
"method": "POST",
"headers": {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "image/jpeg",
"content-length": 45
}
}
}
But when I upload the metadata of the photo, I get the following message:
Request
{
"url": "https://streetviewpublish.googleapis.com/v1/photo?key=YOUR_API_KEY",
"method": "POST",
"headers": {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
"Content-Length": 9385487
},
"data": {
"uploadReference": {
"uploadUrl": "UPLOAD_URL"
},
"pose": {
"heading": 110,
"latLngPair": {
"latitude": -29.937386,
"longitude": -60.996952
}
},
"captureTime": {
"seconds": 1506448064836
}
}
}
Response
{
"error": {
"code": 400,
"message": "Photo does not have upload reference.",
"status": "INVALID_ARGUMENT"
}
}
There are not many references to basing myself and finding the problem. For that reason I would like the help of someone who may have gone through something similar.
I have replicated your issue. I've encountered this error when I didn't specify the UPLOAD_URL in the request.
{
"error": {
"code": 400,
"message": "Photo upload url does not match required format.",
"status": "INVALID_ARGUMENT",
"details": [
{
...
}
]
}
}
Make sure that you have added the UPLOAD_URL in the request. Check this documentation for more information.
I'm the co-owner on a box.com file.
My boss is the owner.
I'm using https://www.npmjs.com/package/box-node-sdk to manage the files
The node client has my bosses' enterprise credentials
He made a folder
I made several other sibling folders
I can retreive his
I can't retreive mine
We're both listed as collaborators on all the files
The error I get looks like this:
{
"statusCode": 404,
"response": {
"statusCode": 404,
"body": {
"type": "error",
"status": 404,
"code": "not_found",
"context_info": {
"errors": [
{
"reason": "invalid_parameter",
"name": "item",
"message": "Invalid value 'd_11786923812'. 'item' with value 'd_11786923812' not found"
}
]
},
"help_url": "http://developers.box.com/docs/#errors",
"message": "Not Found",
"request_id": "338009555580a32f872f7c"
},
"headers": {
"server": "ATS",
"date": "Fri, 21 Oct 2016 15:23:36 GMT",
"content-type": "application/json",
"content-length": "324",
"cache-control": "no-cache, no-store",
"strict-transport-security": "max-age=31536000; includeSubDomains",
"vary": "Accept-Encoding",
"age": "0",
"connection": "keep-alive"
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "api.box.com",
"port": 443,
"hostname": "api.box.com",
"hash": null,
"search": null,
"query": null,
"pathname": "/2.0/folders/11786923812",
"path": "/2.0/folders/11786923812",
"href": "https://api.box.com/2.0/folders/11786923812"
},
"method": "GET",
"headers": {
"User-Agent": "Box Node.js SDK v1.1.0",
"Authorization": "[REMOVED BY SDK]",
"accept": "application/json"
}
}
}
}
EDIT: So, I can get folder 0 and it's not where I'm looking BUT, I did check earlier and added a file where I thought I was looking and it did show up, so I'm guessing that my boss would have to create the files...
Using the Azure Management REST API, I'm trying to update (PATCH) an existing Scheduler job with a retry policy. The request is accepted but the json response object doesn't include the retry policy entries.
In the case of an update, other changes I make are reflected in the response.
Azure Scheduler job entity structure: http://msdn.microsoft.com/library/azure/dn528941.aspx
Azure Scheduler REST API ref: http://msdn.microsoft.com/en-us/library/azure/dn528946.aspx
I've be using Burp Suite to quickly iterate through different requests, but I never see anything to suggest the retry policy has been created.
What am I missing?
The following request will create a new job name SampleJob20 (with no retry policy)
PUT /<subid>/cloudservices/<cloudservicename>/resources/scheduler/~/JobCollections/<jobcollectionname>/jobs/SampleJob20?api-version=2014-04-01 HTTP/1.1
Content-Type: application/json
x-ms-version: 2012-03-01
Host: management.core.windows.net
Content-Length: 583
{
"startTime": "2013-01-30T12:08:00-08:00",
"action":
{
"type": "http",
"request":
{
"uri": "http://bing.com/",
"method": "GET",
"headers":
{
"Content-Type": "text/plain"
}
}
},
"recurrence":
{
"frequency": "minute",
"interval": 30,
"count": 1000
},
"state": "enabled"
}
The response for this request is:
HTTP/1.1 201 Created
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 364
Content-Type: application/json; charset=utf-8
Expires: -1
Server: 1.0.6198.148 (rd_rdfe_stable.141019-1428) Microsoft-HTTPAPI/2.0
x-ms-servedbyregion: ussouth2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
x-ms-request-id: xxxxxxxxxxxxxxxxx
Date: Mon, 20 Oct 2014 19:13:40 GMT
{
"id":"SampleJob20",
"startTime":"2013-01-30T20:08:00Z",
"action":
{
"request":
{
"uri":"http:\/\/bing.com\/","method":"GET",
"headers":
{
"content-Type":"text\/plain"
}
},
"type":"http"
},
"recurrence":
{
"frequency":"minute",
"count":1000,
"interval":30
},
"state":"enabled",
"status":
{
"nextExecutionTime":"2014-10-20T19:38:00Z",
"executionCount":0,
"failureCount":0,
"faultedCount":0
}
}
When I try and update this job with a retry policy. The response is missing the retry policy detail.
PATCH /<subid>/cloudservices/<cloudservicename>/resources/scheduler/~/JobCollections/<jobcollectionname>/jobs/SampleJob20?api-version=2014-04-01 HTTP/1.1
Content-Type: application/json
x-ms-version: 2012-03-01
Host: management.core.windows.net
Content-Length: 451
{
"id": "SampleJob20",
"action":
{
"type": "http",
"request":
{
"uri": "http://bing.com",
"method": "GET",
"headers":
{
"Content-Type": "text/plain"
}
},
"retryPolicy":
{
"retryType":"fixed",
"retryInterval": "PT1M",
"retryCount": 3
}
}
}
If I create a new job with a retry policy the response contains the retry detail. However, the jobs retry policy cannot be updated either.
Can you try putting a new or the same job like this (It includes the retry policy in the Put request)
PUT
{
"startTime": "2013-01-30T12:08:00-08:00",
"action":
{
"type": "http",
"request":
{
"uri": "http://bing.com/",
"method": "GET",
"headers":
{
"Content-Type": "text/plain"
}
},
"retryPolicy":
{
"retryType":"fixed",
"retryInterval": "PT1M",
"retryCount": 3
}
},
"recurrence":
{
"frequency": "minute",
"interval": 30,
"count": 1000
},
"state": "enabled"
}