How to send a multipart/mixed HTTP POST request through Runscope? - request

I want to send a HTTP POST request with Content-Type: Multipart/mixed using Runscope.
Any help/guidance would be great.

There are a couple ways to send data through us, each with varying support for multi-part form data.
Dashboard
When making requests through the dashboard, there is currently no way to add files or other multi-part data to a request. This is something we plan to support in the future, but we don't have a specific timline for implementing it yet.
From your code, via a Runscope URL
When you make a request from code that includes multipart data, it will be relayed through the Runscope URL in tact. The dashboard will display the file meta data that it relayed, but the files are not stored or displayed and retries will not re-send the file data again.
We're happy to help answer any questions in more detail by emailing us at help#runscope.com any time.

Related

How to create custom URL in apex to get Json response from third party application

I am sending some perameters to the third party application using rest api In one of the perameter I am sending A URL, This URL will use by third party application to send a json response after 5 or 10 min. My question is how may i create that URL for third party app that they will use to send the response.
If the 3rd party can send HTTP headers too you could send to them the current user's session id. If that user is API enabled (checkbox in profile/permission set) - you could write an Apex REST service that accepts POSTs. They'd call it with Authorization: Bearer <session id here> and it could work very nice. This trailhead might be a good start for you. (or can you contact their developers and maybe agree to make a dedicated user in SF for them so they'd log in under their own credentials and send it back?)
If they cannot send any special headers (it'd have to be unauthenticated connection to SF) - maybe you could make a Visualforce page, expose it as Site and then page's controller can do whatever you need. Maybe you already have something public facing (community?), maybe it'd be totally new... Check https://developer.salesforce.com/docs/atlas.en-us.206.0.salesforce_platform_portal_implementation_guide.meta/salesforce_platform_portal_implementation_guide/sites_overview.htm
If none of these work for you - does the url have to ping back to Salesforce. Maybe you have control over another server that can accept unauthenticated requests like that and have that one then call SF. Bit like a proxy. You could even set something up fairly easily on Heroku.
Last but not least. This would be extremely stupid but if all else fails - in a sandbox enable Web-to-Case or Web-to-Lead and experiment with these. At the end of the day they give you an url you can POST to and pass a form with data. I think it'd have to be Content-Type: application/x-www-form-urlencoded and if you mentioned JSON they're likely to send it as application/json so might not work. If it works - you could maybe save the payload in Description field of Cases (special record type maybe?) and do something with it. I'm seriously not a fan of this.

Does fetch api or whatwg-fetch modify response with status code 304 to 200?

I'm using Etags in the response headers for dynamic resources, and my client is sending future requests for the same resource with the If-None-Match header.
The client and server are interacting perfectly, and I get 304 responses if the data was not modified. I can see this on the nginx logs on my server, and the browser network tab on Firefox. However, when i log the exact same response from the whatwg-fetch response status, I'm getting 200.
Although react doesn't re-render if there is not diff in the data, all the processing till that point (dispatching actions, running custom data manipulation etc) are being executed, which is consuming too much memory.
I'm using react-boilerplate, which is internally whatwg-fetch, and too far out to make a U-turn and start using xhrHttpRequests, which apparently don't have this problem from the scant resources I found in other parts of the web.
Please help; I can attach logs and notes if need be. Thanks :)

Multipart-form-data POST request for Uploading Files

While integrating FreshDesk in my product,I am stuck with Create Ticket with attachment API. I am using Advanced Rest Client for testing APIs.I have seen many forums and questions on the Stack Overflow itself but I am still not satisfied with any answer pertaining to multipart-form-data POST request for uploading files.
I would like to know the Request Format required in Advanced Rest Client along with headers.
As of now, this is the request I am using but I am not getting a proper response:
-----------------------------7d01ecf406a6
Content-Disposition: form-data;name="files";filename="text1.txt"
Content-Type:text/plain
Its a nice day.
-----------------------------7d01ecf406a6--
I just spent the last hour on this same issue, thinking I was doing something wrong. I eventually gave up on ARC and tried PostMan and set all the values the same and it worked on the server-side (I'm using node.js+hapi) where previously the server was returning 415 with little more info (there's an open issue in Hapi regarding this).
After seeing the requests at the server when using PostMan and considering the UI feedback ARC regarding multi-part (implying it would overwrite any included content-type headers), I've concluded that it's supposed to overwrite/include the content-type header AND provided the boundary, but is not and so my requests were failing.
I've also looked at closed and open issues for ARC ( https://github.com/jarrodek/ChromeRestClient/issues?utf8=%E2%9C%93&q=is%3Aissue%20multipart ) and it looks a lot like there are known issues with multi-part uploads from the client so I'd suggest you not spend too much more time with ARC until you've tried another client to eliminate ARC as the source of your issues.
You need to set proper Content-Type header
Content-Type: multipart/form-data; boundary=---------------------------7d01ecf406a6
Server needs to know what to look for in the request body. In case of multipart/form-data you need to pass the boundary you have used in the Content-Type header.

"No Access Control Allow Origin" in AngularJS

I am trying to develop a website that reads a JSON response from a certain endpoint and post it after certain processing to the page.
I am using $http.get(url) (AngularJS)
However I am facing problems getting the response.
I have tried to use other URLs and it worked then the cause of the problem probably is not the code.
The Error is: "No Access Control Allow Origin header is present on the requested resource".
Other responses suggested something related to CORS and privacy issues ; but when i type the URL directly in my browser it gives a JSON response directly. (So basically there is no privacy issues in the server side right?)
My question is what should I do ? Is there another way to get the content of the page pointed by the url (i am sure that it will only contains the JSON response)
Thanks in Advance
I came across this question:
1. If we substitute the URL in the address bar, it is similar to receiving data from the server of this site
In order to send requests to other servers need to use JSONP HTTPS for secure channel
Sending data can be carried out, but with the replies received will be a problem in the form JSON
Please send to the server if use PHP, then use CURL
JS->Our server->Server api->Our server->JS

duplicate ajax calls in angularjs

I am using express-jwt to build a restful api. Now the client is making duplicate ajax calls, for the first one the initiator is angularjs and for the second one the initiator is other. The first one gets 204 as the response code and the second one gets 200 as the response code. I tried to debug to get to the source of this duplicate requests, but I am not able to.
Below is the header details for the one with 204 status code
Below is the header details for the one with 204 status code
Can any one suggest what could be the issue?
The first call is OPTIONS type. That's a pre-flight call which a browser sends if the page and api are not on same domain.
The purpose of this call is to deal with CORS. Backend usually needs to send the allowed request method types (GET, POST etc.). The browser will then send the real call if the desired request type is among those returned.
Here's a sample of the response headers.
You can ignore it for all intents and purposes. It does not contain any normally useful payload or return data.
Take a look at AJAX in Chrome sending OPTIONS instead of GET/POST/PUT/DELETE? for more info.
Those two requests are different one is OPTIONS and other is GET.
For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server.
You need to handle in the server when the request method OPTIONS , then you need to exit with out processing.

Resources