Trying to Use CFEXECUTE with Curl to Post via API to Rumble - api

I am trying to convert this example script (from Rumble's Upload API) to using CURL:
curl -F "access_token=XXXXX" \ -F "title=A cool video" \ -F "description=Some detailed description" \ -F "license_type=0" \ -F "channel_id=123" \ -F "video=#video.mp4" \ -F "thumb=#thumbnail.jpg" \ "https://rumble.com/api/simple-upload.php"
I've been trying to get the following code working to upload videos via API to our Rumble account. I'm new to Curl and CFEXECUTE but not new to Coldfusion:
<cfexecute name = "/usr/bin/curl" arguments = "-X POST --insecure https://rumble.com/api/simple-upload.php -F access_token=#access# -F title=#titletouse# - F description=#descript# -F license_type=0 -F channel_id=#channel# -F video=##form.video#" variable="response" timeout = "999"> </cfexecute>
Most of the time the response is: [empty string]
The variables listed are required. I'm pretty sure it IS connecting to Rumble because I tried bunch of different versions and one was without POST and got back JSON response data and another was without an -F before description and got back: { "success": false, "errors": { "description": { "code": "MISSING_OR_INVALID_VALUE" } } }
For example, I tried:
with single quotes around each form field '-F license_type=0'
with -H 'Content-Type:multipart/form-data'
with semi colons between fields: -F licensetype=0;-F channel_id=#channel#
Any suggestions on what I'm doing wrong? I have tried about 30 different things.... and am out of ideas. Thank you!!!!!

Related

AWS error when trying to publish an Autodesk Forge Design Automation App bundle

When following the steps described here: https://forge.autodesk.com/en/docs/design-automation/v3/tutorials/revit/step4-publish-appbundle/#step-3-upload-the-appbundle I get an Aws specific error.
<Error><Code>AccessDenied</Code><Message>No AWSAccessKey was presented.</Message>
I have verified my request but it seems that both the header and all form data has been set correctly, as described in this example:
curl -X POST \
https://dasprod-store.s3.amazonaws.com \
-H 'Cache-Control: no-cache' \
-F key=apps/Revit/DeleteWallsApp/1 \
-F content-type=application/octet-stream \
-F policy=eyJleHBpcmF0aW9uIjoiMjAxOC... (truncated) \
-F success_action_status=200 \
-F success_action_redirect= \
-F x-amz-signature=6c68268e23ecb8452... (truncated) \
-F x-amz-credential=ASIAQ2W... (truncated) \
-F x-amz-algorithm=AWS4-HMAC-SHA256 \
-F x-amz-date=20180810... (truncated) \
-F x-amz-server-side-encryption=AES256 \
-F 'x-amz-security-token=FQoGZXIvYXdzEPj//////////wEaDHavu... (truncated)' \
-F 'file=#path/to/your/app/zip'
Of course, all values have been replaced with the response received from
curl -X POST \
https://developer.api.autodesk.com/da/us-east/v3/appbundles \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": "DeleteWallsApp",
"engine": "Autodesk.Revit+2018",
"description": "Delete Walls AppBundle based on Revit 2018"
}'
Now, since this is an AWS specific error, maybe there have been some changes to the AWS api and are the examples given in the forge documentation not up to date?
This seemed to be a client issue.
I am using the request npm package in node.js and did set the formData as part of the form attribute, instead of the formData attribute.
const request = require('request-promise');
return request.post(uploadParameters.endpointURL, {
headers: {
'Content-Type': 'multipart/form-data',
'Cache-Control': 'no-cache'
},
formData: { // use formData instead of form
...uploadParameters.formData,
file: fs.createReadStream(EXPECTED_APPBUNDLE_PATH)
}
})
Glad you figured out what was going on :)
If you want a nodejs sample/example for Design Automation, you can take a look at this repository. Even tough it has been built for 3ds Max, the Design Automation concepts are still the same.
https://github.com/Autodesk-Forge/design.automation.3dsmax-nodejs-basic/blob/master/createAndUploadApp.js
Hopefully, something in there can be useful to you.

Any way to use presigned URL uploads and enforce tagging?

Is there any way to issue a presigned URL to a client to upload a file to S3, and ensure that the uploaded file has certain tags? Using the Python SDK here as an example, this generates a URL as desired:
s3.generate_presigned_url('put_object',
ExpiresIn=3600,
Params=dict(Bucket='foo',
Key='bar',
ContentType='text/plain',
Tagging='foo=bar'))
This is satisfactory when uploading while explicitly providing tags:
$ curl 'https://foo.s3.amazonaws.com/bar?AWSAccessKeyId=...&Signature=...&content-type=text%2Fplain&x-amz-tagging=foo%3Dbar&Expires=1538404508' \
-X PUT
-H 'Content-Type: text/plain' \
-H 'x-amz-tagging: foo=bar' \
--data-binary foobar
However, S3 also accepts the request when omitting -H 'x-amz-tagging: foo=bar', which uploads the object without tags. Since I don't have control over the client, that's… bad.
I've tried creating an empty object first and tagging it, then issuing the presigned URL to it, but PUTting the object replaces it entirely, including removing any tags.
I've tried issuing a presigned POST URL, but that doesn't seem to support the tagging parameter at all:
s3.generate_presigned_post('foo', 'bar', {'tagging': '<Tagging><TagSet><Tag><Key>Foo</Key><Value>Bar</Value></Tag></TagSet></Tagging>'})
$ curl https://foo.s3.amazonaws.com/ \
-F key=bar \
-F 'tagging=<Tagging><TagSet><Tag><Key>Foo</Key><Value>Bar</Value></Tag></TagSet></Tagging>'
-F AWSAccessKeyId=... \
-F policy=... \
-F signature=... \
-F file=#/tmp/foo
<Error><Code>AccessDenied</Code><Message>Invalid according to Policy:
Extra input fields: tagging</Message>...
I simply want to let a client upload a file directly to S3, and ensure that it's tagged a certain way in the process. Any way to do that?
Try the following code:
fields = {
"x-amz-meta-u1": "value1",
"x-amz-meta-u2": "value2"
}
conditions = [
{"x-amz-meta-u1": "value1"},
{"x-amz-meta-u2": "value2"}
]
presignedurl = s3_client.generate_presigned_post(
bucket_name, "YOUR_BUCKET_NAME",
Fields=copy.deepcopy(fields),
Conditions=copy.deepcopy(conditions)
)
Python code:
fields = {
'tagging': '<Tagging><TagSet><Tag><Key>Foo</Key><Value>Bar</Value></Tag></TagSet></Tagging>',
}
conditions = [
{'tagging': '<Tagging><TagSet><Tag><Key>Foo</Key><Value>Bar</Value></Tag></TagSet></Tagging>'}
]
presigned_url = s3_client.generate_presigned_post(
Bucket="foo",
Key="file/key.json",
Fields=copy.deepcopy(fields),
Conditions=copy.deepcopy(conditions)
)
CURL command:
$ curl -v --form-string "tagging=<Tagging><TagSet><Tag><Key>Foo</Key><Value>Bar</Value></Tag></TagSet></Tagging>" \
-F key=file/key.json \
-F x-amz-algorithm=... \
-F x-amz-credential=... \
-F x-amz-date=... \
-F x-amz-security-token=... \
-F policy=...\
-F x-amz-signature=... \
-F file=#key.json \
https://foo.s3.amazonaws.com/
Explanation
It is imperative that --form-string is used in the CURL command, otherwise CURL will interpret the =< as reading in a file!
Also ensure that key.json is in your current working directory for CURL to upload the file to S3 using the pre-signed-url.

How to POST a MultiPart/Form data from VB.NET

I'm currently developing a VB.NET program in Visual Studio 2017, and while I'm reasonably competent with most aspects of VB.NET, this one has me completely stumped.
The program needs to POST multipart/form data to Mixcloud (which is like Soundcloud but for radio programmes). After some research, all I have found are dead ends. In Mixcloud's API for uploading (found here), they give a CURL example on how to do it. Would anyone have an idea on how to implement this in VB.NET? Many thanks in advance for any help available.
Here is their example:
curl -F mp3=#upload.mp3 \
-F "name=API Upload" \
-F "tags-0-tag=Test" \
-F "tags-1-tag=API" \
-F "sections-0-chapter=Introduction" \
-F "sections-0-start_time=0" \
-F "sections-1-artist=Artist Name" \
-F "sections-1-song=Song Title" \
-F "sections-1-start_time=10" \
-F "description=My test upload" \
https://api.mixcloud.com//upload/?access_token=INSERT_ACCESS_TOKEN_HERE
(The "sections" are essentially markers that are shown on the player to highlight different points of a radio show - just to provide some context!)

How to create instagram API subscription using cURL

Following the instagram API documentation, I ran the following in the command line:
$ curl -F 'client_id=my_client_id' \
> -F 'client_secret=my_client_secret' \
> -F 'object-geography' \
> -F 'aspect=media' \
> -F 'lat=35.657872' \
> -F 'lng=139.70232' \
> -F 'radius=1000' \
> -F 'callback_url=http://http://requestb.in/my_string' \
> https://api.instagram.com/v1/subscriptions/
and got the following error:
Warning: Illegally formatted input field!
curl: option -F: is badly used here
curl: try 'curl --help' or 'curl --manual' for more information
I did try curl --help and curl --manual, but wasn't able to figure this out based on their contents. How might I successfully create a subscription?
You are facing problem with this one:
> -F 'object-geography' \
It supposed to be Key=Value paired parameter. But you are using only one. So check this out. Probably it will be
> -F 'object=geography' \
^ check this

Error submitting iOS .app using TestFlight API

I'm running the following script:
#!/bin/bash
archive=`./builds/myapp.ipa`
curl http://testflightapp.com/api/builds.json
-F file=$archive
-F api_token='xxxxxxxxxxxxxxxxxxxxxxxxxx'
-F team_token='xxxxxxxxxxxxxxxxxxxxxxxxxx'
-F notes='here comes the new app!'
-F notify=True
-F distribution_lists='MyFriends'
but I'm getting the error:
You must supply api_token, team_token, the file and notes (missing
file)
I'm actually copy/past-ing the script from the TestFlight website. What's wrong with that?
Please note that, as seen in the example given in the TestFlight API Documentation, you need to use the '#' character before the IPA file name.
You should try with:
#!/bin/bash
archive=`./builds/myapp.ipa`
curl http://testflightapp.com/api/builds.json \
-F file=#$archive \
-F api_token='xxxxxxxxxxxxxxxxxxxxxxxxxx' \
-F team_token='xxxxxxxxxxxxxxxxxxxxxxxxxx' \
-F notes='here comes the new app!' \
-F notify=True \
-F distribution_lists='MyFriends'