Hi Team, I am trying to automate the Logical Data...
# gooddata-cloud
p
Hi Team, I am trying to automate the Logical Data model using API calls. I was able to export the LDM content to a json file but when I try to restoe it to my target workspace model, I face error. Please find the details mentioned below. Target workspace: smartlocalconnect-dileep. curl command: curl -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -X PUT \ -d @test.json https://phlexglobal-test.cloud.gooddata.com/api/v1/layout/workspaces/e809c3653fe94319b34aaf4a3e6b71ed/logicalModel error:"detail":"Data source dataSource='8599de47-7e86-4303-9d61-775ccc22b222' does not exist or you do not have permission to access it.","status":400,"title":"Bad Request"
j
Hi Prashanth, Just to be sure, I was just testing this and I had no issue to migrate the LDM. However, I was migrating it into an empty workspace. Can you please confirm if there are already any datasources and LDM in your target workspace? Are you migrating an LDM created from the same datasource which is also already present in your destination workspace?
p
I was able to fix this, the datasource id was old one only, I have replaced my target datasource id in json and tried, it worked. A few feedback points, 1. I will try to pass the target datasource during command execution as a parameter, but I want to know if there is any flag you have for this. 2. Also, the get call is giving JSON without a format; it would be better if it were formatted properly. I have not tried importing without doing any formatting, but let me know if I am missing any. I am new to GD, and your guidance will help me.
m
Hi Prashanth, Thank you for the update and for sharing your findings! We're glad to hear you were able to resolve the import issue by updating the data source ID in the JSON payload. Before answer the follow-up questions, may I ask how are you performing the API calls? are you using some tool like Postman (recommend) or, for example you are using CURL in some python script? For 1) you mean if you can add the dataSource_id as variable in the body, or in. the uri? Exactly, which endpoint you are using? Can you confirm your body looks like this example https://www.gooddata.com/docs/cloud/api-and-sdk/api/api_reference_all/#operation/setLogicalModel?