We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

How to Convert USDZ to GLTF using cURL with Aspose.3D REST API?

Hello,

I managed to upload a file to the storage successfully using

curl -v -X PUT "https://api.aspose.cloud/v3.0/3d/storage/file/framedpicture.usdz" "Content-Type:application/octet-stream" -H "Authorization: Bearer xxxxx" --ssl-no-revoke --data-binary @framedpicture.usdz

(By the way, the official documentation has two errors here: correct is PUT not POST, and correct is --data-binary not --binary)

But now the conversion command doesn’t seem to work:

curl -X POST "https://api.aspose.cloud/v3.0/3d/saveas/newformat?name=framedpicture.usdz&newformat=gltf&newfilename=framedpicture.gltf&IsOverwrite=true" -H "accept: application/json" -H "authorization: Bearer xxxxx"

There is no answer from the API, and the token seems to have worked for the upload, so I assume it should also work for the conversion immediately thereafter.

Does anybody know what the problem could be?

Thanks! :grinning_face_with_smiling_eyes:

@cburgdorfer

We are sorry for the inconvenience. We will update the documentation. Meanwhile, you can try following cURL command to convert USDZ to GLTF.

Convert USDZ to GLTF with Aspose.3D Converter API

# First get Access Token
# Get Customer Key and Customer ID from https://dashboard.aspose.cloud/
curl -X POST "https://api.aspose.cloud/connect/token" 
-d "grant_type=client_credentials&client_id=xxxxx-xxxx-xxxx-xxxx-xxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxx" 
-H "Content-Type: application/x-www-form-urlencoded" 
-H "Accept: application/json"

# Upload File to Cloud Storage
curl -X PUT "https://api.aspose.cloud/v3.0/3d/storage/file/Temp/test.usdz"
-H "accept: application/json"
-H "authorization: Bearer [Access_Token]"
-H "Content-Type: multipart/form-data"
-T "C:/Users/hp 840 g3/Downloads/test.usdz"

About the file conversion issue, please share your input document with us. We will try to replicate the issue and share our findings with you. You may test Aspose.3D Cloud right away in your browser with Web API Explorer. It provides a sample cURL command of API call as well.

1 Like

Thanks for your help @tilal.ahmad - what’s the best way to share it with you? I have a screen recording that contains confidential information.

@cburgdorfer

You may share your input file with me as a private message. Please check this following post for details.

1 Like

@cburgdorfer

Thanks for sharing the details. I have tested the UploadFile API method and PostConvertByFormat API method without any issue. However, please note PostConvertByFormat API method does not return any reply but saves the output document on storage. Please check your storage for the output file.

1 Like

@cburgdorfer

I have tested USDZ to GLTF conversion with your sample and got the following exception. So logged a ticket THREEDCLOUD-69 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

"Error": {
    "Code": "internalError",
    "Message": "Stream incorrect or unsupported! Cannot open this file",
    "Description": "Operation Failed. Internal error.",
    "DateTime": "2022-02-17T16:46:40.9089302Z",
    "InnerError": null
  }
}
1 Like

Oh, ok, great, thanks a lot @tilal.ahmad! Much appreciated!

1 Like

Hi @tilal.ahmad … in case you guys can’t resolve this issue quickly, perhaps you can tell me what’s different between your USDZ and my USDZ, and I can perhaps change my USDZs?

Just in the interest of being able to unblock my side…

Thanks,
Christoph

@cburgdorfer

Thanks for your feedback. We have recorded your concern and will share our initial findings with you soon.

1 Like

@cburgdorfer

Thanks for your patience. We have fixed the above reported issue. Please try now, it will work as expected.

1 Like

I am really trying and trying and it still doesn’t work :frowning:

  1. Do I need a specific type of account?
  2. Can you send me the file you are trying with?
  3. Can there be any other reason why it works for you but not for me?
  4. Is there a way to find out an error message or an error log?
  5. Does it take a while to convert? If so, how long? Hours maybe?

Thanks a lot,
Christoph

@cburgdorfer

No, you do not need any specific account. The Free Trial plan provides all the functionalities and features except the 150 API monthly limit.

As shared in the private message. I’m able to convert your shared file using the following cURL command. Please check your cloud storage for the output and confirm

//Convert USDZ to GLTF
curl -X POST "https://api.aspose.cloud/v3.0/3d/saveas/newformat?name=framedpicture.usdz&newformat=gltf&newfilename=framedpicture.gltf&IsOverwrite=true" 
-H "accept: application/json" 
-H "authorization: Bearer [Access_Token]"

You may check your usage logs from your aspose.cloud dashboard.

It depends upon the file size/contents and network. However, it should be converted within seconds.

1 Like

@tilal.ahmad I have tried to use your codes and instructions verbatim, but the requests do not seem to reach your back end if I trigger them (can’t even see any of the requests in the log, while the others arrive).

Can you please confirm that you are not in some sort of VPN, have a whitelisted IP address, or anything of such nature?

I can see the requests works for you. But the exact same code (of course with the correct Bearer token) does not work if I try it from any of my servers, using curl on Mac or Linux.

Thanks,
Christoph

@cburgdorfer

No, I’m not using any VPN or some special arrangements. It is quite strange that the Upload File API request is working fine at your end but Conversion is failing.

Did you try the conversion from some other computer?

Can you please test the following C# code with your credentials using Aspose.3D Cloud NuGet Package and share the result?

using Aspose.ThreeD.Cloud.SDK.Api;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static String ClientId = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxx";
        static String ClientSecret = "xxxxxxxxxxxxxxxxxxxx";


        static void Main(string[] args)
        {
            Convert_3d();
            Console.WriteLine("Completed...");
            Console.ReadKey();
        }
        public static void Convert_3d() {

            var threeDCloudApi = new ThreeDCloudApi("client_credentials", ClientId, ClientSecret);
            
            string name = "framedpicture.usdz";
            string newformat = "gltf2";
            string newfilename = "framedpicture.gltf";
            //string folder = "3DToPdf";
            bool isOverwrite = true;
            //string storage = "MyStorage";

            var response = threeDCloudApi.PostConvertByFormat(name, newformat, newfilename, null, isOverwrite, null);

        }
    }
}

Thanks @tilal.ahmad - yes I tried from multiple computers/servers with different OSes in different countries. None of them managed to trigger a /saveas command with cURL that shows in the activity log. The other commands showed in the activitiy logs (and worked).

Thanks for the C# code, I will try it and get back to you. Your help is much appreciated!

1 Like

By the way, I’ve found the solution. Your server seems to reject the request if the content length is 0 but the header doesn’t indicate that content length will be zero. Therefore adding the parameter -d "" to the cURL command seems to have solved the problem.

curl -v -d "" -X POST "https://api.aspose.cloud/v3.0/3d/saveas/newformat?name=framedpicture3.usdz&newformat=gltf&newfilename=framedpicture3.gltf&IsOverwrite=true" -H "accept: application/json" -H "authorization: Bearer ..."

Thanks again for your help! Much appreciated.

1 Like

@cburgdorfer

It is good to know that you have managed to resolve the issue. It might be the cURL version as the request calls are working fine with me without -d cURL parameter.

1 Like