Translate revit model to svf from bucket id - autodesk-forge

Im trying to translate a revit model to svf using this endpoint https://developer.api.autodesk.com/modelderivative/v2/designdata/job
According to the docs this endpoint needs at lest these two attributes to work:
urn
formats
First I got the objectId from the desired object inside my bucket :
"objectId":"urn:adsk.objects:os.object:gkwz1o52jxgqnqkhay5dlgcg7e2xglal_tutorial_bucket/rst_basic_sample_project.rvt"
and then I used https://www.base64encode.org/ to encode this string and get my urn, following the advice from this question how to get the urn of the bucket file. The result urn was this:
dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6Z2t3ejFvNTJqeGdxbnFraGF5NWRsZ2NnN2UyeGdsYWxfdHV0b3JpYWxfYnVja2V0L3JzdF9iYXNpY19zYW1wbGVfcHJvamVjdC5ydnQ=
Finally I got the format from the examples and I removed the = from the urn string.
My final body data is this:
{
"input": {
"urn": "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6Z2t3ejFvNTJqeGdxbnFraGF5NWRsZ2NnN2UyeGdsYWxfdHV0b3JpYWxfYnVja2V0L3JzdF9iYXNpY19zYW1wbGVfcHJvamVjdC5ydnQ"
},
"output": {
"formats": [
{
"type": "svf",
"views": ["2d", "3d"]
}
]
}
}
But im getting this message:
I thought that was I getting the right object, and getting the urn, but still don't know what I'm doing wrong.

The endpoint URL, payload, and the base64-encoded object ID all seem to be fine. Try a couple of things:
Make sure that you that you're using POST method when calling the endpoint
Make sure that you're using the same Forge credentials (client ID and secret) you used when uploading the Revit model to the bucket
Try other ways of calling the endpoint, for example, using Postman or the VSCode extension

Related

How I can convert JSON to payload of HTTP GET string?

I am trying to get data using GDC portal api. As it is shown in GDC API, to send an HTTP GET request, we need to have a format similar to:
https://api.gdc.cancer.gov/files?filters=%7B%22op%22%3A%22and%22%2C%22content%22%3A%5B%7B%22op%22%3A%22in%22%2C%22content%22%3A%7B%22field%22%3A%22cases.submitter_id%22%2C%22value%22%3A%5B%22TCGA-CK-4948%22%2C%22TCGA-D1-A17N%22%2C%22TCGA-4V-A9QX%22%2C%22TCGA-4V-A9QM%22%5D%7D%7D%2C%7B%22op%22%3A%22%3D%22%2C%22content%22%3A%7B%22field%22%3A%22files.data_type%22%2C%22value%22%3A%22Gene%20Expression%20Quantification%22%7D%7D%5D%7D&format=tsv&fields=file_id,file_name,cases.submitter_id,cases.case_id,data_category,data_type,cases.samples.tumor_descriptor,cases.samples.tissue_type,cases.samples.sample_type,cases.samples.submitter_id,cases.samples.sample_id,analysis.workflow_type,cases.project.project_id,cases.samples.portions.analytes.aliquots.aliquot_id,cases.samples.portions.analytes.aliquots.submitter_id&size=1000
Which is a format from json payload as:
{
"filters":{
"op":"and",
"content":[
{
"op":"in",
"content":{
"field":"cases.submitter_id",
"value":[
"TCGA-CK-4948",
"TCGA-D1-A17N",
"TCGA-4V-A9QX",
"TCGA-4V-A9QM"
]
}
},
{
"op":"=",
"content":{
"field":"files.data_type",
"value":"Gene Expression Quantification"
}
}
]
},
"format":"tsv",
"fields":"file_id,file_name,cases.submitter_id,cases.case_id,data_category,data_type,cases.samples.tumor_descriptor,cases.samples.tissue_type,cases.samples.sample_type,cases.samples.submitter_id,cases.samples.sample_id,analysis.workflow_type,cases.project.project_id,cases.samples.portions.analytes.aliquots.aliquot_id,cases.samples.portions.analytes.aliquots.submitter_id",
"size":"1000"
}
I wanna add more fields to the payload json and get the equivalent http query string format. I have tried some online convertors, like: JSON-to-String Convertor. Copying the above JSON gives me the below result:
"{\"filters\":{\"op\":\"and\",\"content\":[{\"op\":\"in\",\"content\":{\"field\":\"cases.submitter_id\",\"value\":[\"TCGA-CK-4948\",\"TCGA-D1-A17N\",\"TCGA-4V-A9QX\",\"TCGA-4V-A9QM\"]}},{\"op\":\"=\",\"content\":{\"field\":\"files.data_type\",\"value\":\"Gene Expression Quantification\"}}]},\"format\":\"tsv\",\"fields\":\"file_id,file_name,cases.submitter_id,cases.case_id,data_category,data_type,cases.samples.tumor_descriptor,cases.samples.tissue_type,cases.samples.sample_type,cases.samples.submitter_id,cases.samples.sample_id,analysis.workflow_type,cases.project.project_id,cases.samples.portions.analytes.aliquots.aliquot_id,cases.samples.portions.analytes.aliquots.submitter_id\",\"size\":\"1000\"}"
So, I tried to get data using the generated string by adding
https://api.gdc.cancer.gov/files?
to the beginning of that. But, running this, gives me a different output. So, how can I convert the JSON to exactly what is given in GDC website? Sorry, I am very new to API and their usages.

Postman: POST request of nested JSON via form-data not working (while via raw-data ok)

I want to POST the following JSON-object via Postman:
{
"title": "test_title",
"date": "2021-12-31",
"attachments": [
{
"name": "test_attachment"
}
]
}
This works perfectly fine, when using Postman's raw input form for the request-body: I get a "201 Created"-response back.
However, when using the form-data to POST the data, I get the error "Invalid data. Expected a dictionary, but got str." (see also screenshot below) What am I doing wrong here? I tried all kind of other versions to enter the attachment-key:value pair but nothing worked so far
I managed to make it work! (note: I added some additional fields compared to the screenshot in question. See below for details:
You did nothing wrong.
If you want to make a request with json object, then you go with raw type (json) in postman.
If you want to upload file, then you use form-data
One more thing, status 201 means the request is succeed, your object has been created.
var express = require('express')
const multer = require('multer')
const upload = multer()
var app = express()
app.use(express.json());
app.post('/test',upload.none(), function (req, res, next) {
res.send(req.body)
})
app.listen(80, function () {
console.log('web server listening on port 80')
})
Above is a sample endpoint which works with both form-data and json , just do a post to http://localhost:80/test with both form data and raw json
you can see both will get parsed correclty
APIs are just abstraction , its like a function that takes in many attribute, how you parse it depends on the implementation ( how the api function is written) .
so answer is "Talk to the developer" on how the API is implemented and what it is supporting
I'm having issue in placing json into form format the way Daniel did in Postman. Need help in figuring out what is it required to place the cascaded json objects into form data format. Please see here that I'm trying to accomplish.
JSON Format (to be filled into Postman form-data section:
{
"primary_object": {
"child_object_1": [{"id": 12345678, "value": "abc"},{"id": 87654321, "value": "xyz"}],
"child_object_2": [
"first_val",
"second_val"
]
}
}

Error while trying to Display an SVF from a BIM 360 URN

I'm trying to display a revit model stored in BIM 360 using the code example from this repository: https://github.com/Autodesk-Forge/forge-tutorial-postman/blob/master/docs/display_svf.html
In this html file I only need to give my access token and the URN (encoded). This works if my model is uploaded from a bucket I had created, but I'm getting an Failed fetching Forge manifest error when I try to do it from an URN that I got from a BIM 360 document.
These are the steps I'm taking:
Getting the document URN
I used this endpoint https://developer.api.autodesk.com/data/v1/projects/b.ef7b0d22-8480-40d6-9749-12e5d7192ac9/folders/urn:adsk.wipprod:fs.folder:co.nAdJ4fwLRRuGem-qpDIlTA/contents
And from the results I get my urn:
Encode the URN
After that I got to https://www.base64encode.org/ and encode the value
urn:adsk.objects:os.object:wip.dm.prod/ac9e8b48-4a51-4f6a-a7e4-a947c9d6a1e6.rvt
And the result is this:
dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6d2lwLmRtLnByb2QvYWM5ZThiNDgtNGE1MS00ZjZhLWE3ZTQtYTk0N2M5ZDZhMWU2LnJ2dA
Set my access token and encoded URN in display_sfv.html
After that I place my acces token and the encoded URN, like this:
Finally I got this errors from the console:
Again this example works if I use and urn from a bucket I had created, but when I use the urn I get from a BIM 360 folder I get that error message. Where could be my mistake?
To load models form BIM360, you have to use the urn under derivatives attribute like below:
"derivatives": {
"data": {
"type": "derivatives",
"id": "dXJuOmFkc2sud2lwcWE6ZnMuZmlsZTp2Zi50X3hodWwwYVFkbWhhN2FBaVBuXzlnP3ZlcnNpb249MQ"
},
"meta": {
"link": {
"href": "/modelderivative/v2/designdata/dXJuOmFkc2sud2lwcWE6ZnMuZmlsZTp2Zi50X3hodWwwYVFkbWhhN2FBaVBuXzlnP3ZlcnNpb249MQ/manifest?scopes=b360project.6f8813fe-31a7-4440-bc63-d8ca97c856b4,global,O2tenant.tenantId"
}
}
},
Ref: https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-version_id-GET/

freeradius 3.0.17 rlm_rest parsing json response

I'm trying to authenticate RADIUS Requests against a RESTful API (provided by Customer) using rlm_rest.
The problem I am facing is that
response JSON format (of REST API provided by Customer), is different from rlm_rest default format (indicated in etc/raddb/mods-enabled/rest).
My Virtual Server configuration as below:
Default
authorize {
...
...
rest
if (ok) {
update control {
Auth-Type := rest
}
}
}
mods-enabled/rest
authorize {
uri = "https://3rd-party-API/auth"
method = 'post'
body = 'json'
chunk = 0
tls = ${..tls}
data = '{
"code": 1,
"identifier": %I,
"avps": {
"User-Name": ["%{User-Name}"],
"NAS-IP-Address": ["%{NAS-IP-Address}"],
"Called-Station-Id": ["%{Called-Station-Id}"],
"Calling-Station-Id": ["%{Calling-Station-Id}"],
"NAS-Identifier": ["%{NAS-Identifier}"]
}
}'
}
Result
/sbin/radiusd -Xxx
HTTP response code
200
JSON Body
{
"code": "2",
"identifier": "91",
"avps": {
"Customer-Attributes": "Hello"
...
...
"Acct-Interim-Interval": "300"
}
}
The JSON structure is different from the example, and xlat parse
"code"
"identifier"
"avps"
And, of course, xlat finds no attributes match with the dictionary, while it cannot find "avps" and won't dig deeper.
So I was wondering is there anyway to either
Define the response JSON structure for xlat to parsing
Insert a "is_json" or "do_xlat" flag into the JSON ("avps"), and hope xlat will then dig deeper
Save the JSON and parse with exec/rlm_exec (using JQ or any other bash/JSON tools)
Please advise if there is any workaround. Thanks!
In FreeRADIUS version 4, there's a rlm_json module, which implements a custom node query language based on xpath (jpath), it is extremely limited and only supports some very basic queries (feel free to enhance it via PR :) ).
Below is an example I pulled out of my library of customer configurations. You can see here it's pulling out two keys (externalID and macAddress) from the root level of the JSON doc and assigning them to a couple of custom attributes (Subscriber-ID and Provisioned-MAC).
map json "%{rest_api:https://${modules.rest[rest_api].server}/admin/api/${modules.rest[rest_api].api_key}/external/getDeviceBySerialNumber?certificateSerialNumber=%{lpad:&TLS-Client-Cert-Serial 40 0}}" {
&Subscriber-ID := '$.externalId'
&Provisioned-MAC := '$.macAddress'
}
The xlat expansion can also be modified to send HTTP body data. Just put a space after the URL and pass your custom JSON blob.

Facebook API - Batch upload photos

I'm trying to batch upload photos and I keep getting a response back from Postman saying "Batch parameter must be a JSON Array" Does anyone see what is wrong with this because it looks like valid json to me. I've been rattling with this for a few hours making minor tweaks trying to get it to upload to no avail. I also have tried encoding the url.
https://graph.facebook.com/v2.11?batch=[{"method":"POST", "relative_url":"https://graph.facebook.com/v2.11/{pageid}/photos?access_token={access-token}", "body":"link_url":"https://{link-to-image}/wmphotos/999995/6d5cc4169bbf4e7dbe31f3739e025412/a572c29dff_640.jpg"}]&access_token={access-token}
Looking at your code, it seems that the JSON object in your batch array is actually malformed. body:link_url:link should be body: {link_url:link}
Bad:
[
{
"method":"POST",
"relative_url":"foo",
"body":"link_url":"link"
}
]
Good:
[
{
"method":"POST",
"relative_url":"foo",
"body":{"link_url":"link"}
}
]