I am having trouble with creating POST JOB (new name for registration of file in OSS for translation). I have already uploaded ZIP file to the bucket (containing 2 revit files, first is root, second is a revitlink) using segment upload, have its URN and now I want to trigger translation to SVF. For this purpose I am using this piece of code (used Restharp, Newtonsoft.Json):
public void CreatePostJOB(string serviceUrl, string urn, string rootFile, string token)
{
try
{
RestClient client = new RestClient(serviceUrl);
RestRequest request = new RestRequest();
request.Method = Method.POST;
request.Resource = "modelderivative/v2/designdata/job";
request.RequestFormat = DataFormat.Json;
request.AddParameter("Authorization", "Bearer " + token, ParameterType.HttpHeader);
request.AddParameter("x-ads-force", true);
request.AddParameter("Content-Type", "application/json");
JObject jsonbody = new JObject
(
new JProperty("input", new JObject
(
new JProperty("urn", urn),
new JProperty("compressedUrn", true),
new JProperty("rootFileName", rootFile)
)),
new JProperty("output", new JObject
(
new JProperty("formats", new JArray
(
new JObject
(
new JProperty("type", "svf"),
new JProperty("views", new JArray("3d", "2d"))
)
))
))
);
string post = jsonbody.ToString(Formatting.Indented);
request.AddParameter("application/json", post, ParameterType.RequestBody);
IRestResponse resp = client.Execute(request);
if (resp.StatusCode == HttpStatusCode.OK)
{
//TODO
}
}
catch (Exception ex)
{
//TODO
}
}
Code above will produce following JSON into post variable:
{
"input": {
"urn": "/*urn base64 string with no padding*/",
"compressedUrn": true,
"rootFileName": "MainModel_A.rvt"
},
"output": {
"formats": [
{
"type": "svf",
"views": [
"3d",
"2d"
]
}
]
}
No matter how I change this code result is always the same:
{"diagnostic":"Request body is not a valid json"}
I also tried to use ordinary C# WebRequest with same result. Maybe there is a bug, because other calls from the same API works with restsharp like a charm. Please how do I create a valid post job in C#?