Facebook photos api: Please reduce the amount of data you're asking - reactjs

I've setup two business developer applications (test & prod environments) to handle Facebook Login and posting an image to a group directly via a web app. The endpoint I'm using is the following:
https://graph.facebook.com/v14.0/{group-id}/photos?access_token={access_token}
I followed this documentation: https://developers.facebook.com/.../refer.../page/photos/...
with a POST request and Content-Type: multipart/form-data.
The request payload looks like the following:
-----------------------------41883366036964688284103242839
Content-Disposition: form-data; name="source"; filename="blob"
Content-Type: image/png
�PNG
{a bunch of alphanumeric chars........}
-----------------------------41883366036964688284103242839
Content-Disposition: form-data; name="caption"
{the caption of the image}
-----------------------------41883366036964688284103242839--
The test environment works flawlessly: I build the picture in javascript and then call the api endpoint against a test facebook group.
On the production environment, the VERY SAME call with the very same image returns the error:
"Please reduce the amount of data you're asking for, then retry your request"
The post actually makes his way on the Facebook group but without the image.
I tried putting the limit=1 param with no luck.
I tried "cross-posting" with the Facebook PROD app to the Facebook TEST group and it works, so it seems the problem is posting to the PROD Facebook group.
In the image below what I see in the browser when the request fails, it seems the image size is below the 4Mb limit given by Facebook. Is there a better way to check the size of the image I'm trying to send?
However, if the image is the same, how come in one group I get to post correctly and in the other I don't?
How can I overcome this?

Related

POST http request for WIX database gives error

I built a wix website and wanted to have a database to accept data from a Form. I wrote the codes in wix corvid to accept data after some research. Please refer to attached image links for the code.
In order to test the same, I used http://www.apirequest.io. And it gives me the following error:
Error Submitting Request
Error: Request has been terminated Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.
If you site enforces CORS (i.e. Access-Control-Allowed-Origin is set to something other than *), then you may need to allow http://www.apirequest.io.
Regarding the permissions, I have made sure from the settings that 'Anyone can submit data to this collection'.
I am an absolute beginner for web development and http requests. Please support where I went wrong. I would be happy to do further reading on these subjects, please help.
enter image description here
enter image description here
The above question is solved and now it seems that it shouldn't have been here! I was making an error in generating the Http Request.
In case any anyone else is working with wix, the above code is correct in the attached images is correct.
The following http request triggers it:
POST /_functions/firstfunc HTTP/1.1
Host: example.com
Content-Type: application/json
Content-Length: 45
{"Title": "Mr.",
"Name": "John",
"Age": "58"}

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.

Microsoft Store collection REST API, Create Azure AD access tokens returns 404

I'm following the Tutorial "Manage product entitlements from a service" here,
Am getting stuck on step 3, where calls to request an access token return a 404 error.
Step1: In Azure Portal,
Created new WebApp, gave it a name & accepted all the defaults.
Selected the default AD directory and registered the app (used the
APP URL as the login URL).
Grabbed the AP ID _APP_ID_ and created app key _APP_SECRET_.
Updated manifest, replaced identifierURIs as described.
"identifierUris" : [
"https://onestore.microsoft.com",
"https://onestore.microsoft.com/b2b/keys/create/collections",
"https://onestore.microsoft.com/b2b/keys/create/purchase"
],
Step2: In MS DevCenter
Added _APP_ID_ to "Services-> Product collections and purchases -> Client ID".
Step3: Testing using Postman
I pulled the Azure AD Tenant ID _TENANT_ID_ from the PortalDiagnostics.json.
Using the provided sample, I used postman to post as follows:
POST https://login.microsoftonline.com/_TENANT_ID_/oauth2/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded; charset=utf-8
grant_type=client_credentials
&client_id=_APP_ID_
&client_secret=_APP_SECRET_
&resource=https://onestore.microsoft.com
Host and content type are set in the headers, remainder is posted as raw text in the body.
POSTMAN with headers & body
POSTMAN headers
POSTMAN body
As you can see, the result is a 404 with no body, making this a little tough to trouble shoot.
Question:
Have I missed something obvious in steps 1 & 2?
Should I be able to test this with POSTMAN?
I'd appreciate any pointers; I can't find any other tutorials to cross reference.
So in this case the problem was a rogue HTTP/1.1 at the end of the URL + some unencoded content in the form data. Using Postman's x-www-form-urlencoded tab helped for that since it encodes all the fields for you.

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

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.

c read authentication from url and favicon.ico

I'm working on a C coded server that have to reply to browsers' requests. It have to give authentication when using url like this:
http://user:pass#website/
but I really don't know how or where get this information on my server, because what I got when I read the request is the same that I can read when I interact with the server simply using
http://website/
Second question is that sometime I have this favicon.ico request from browsers.. what can I reply to the browser to say "I have not this fu*** stupid icon"? :D
I'm of course using socket for this
Look for a request header named Authorization: containing the string Basic followed by the BASE64 encoded username and password. This method of authenticating is called HTTP Basic Authentication.
For the favicon, simply respond with a HTTP 404 response if you don't have one.

Resources