BookmarkSubscribeRSS Feed
MWallace
Calcite | Level 5

Hi, 

I am trying to use Rest APIs to extract, version control with GIT and replace Visual Analytics content. (in VIYA V.03.05). I have mapped a GIT repo to Home in SAS studio and successfully used Proc http GET to extract the json content. As a test I created a dummy VA report with a single textbox. My plan was to extract the json, change the text manually and use PUT to overwrite the report content. The GET is successful and I extract the Etag correctly but I always get the 10755 error: An Error occurred. The content is invalid, possibly in the wrong format. This happens even if I don't edit the json at all or even just pass the extracted file back to the PUT.

My code is as follows:

 
/* === EXTRACT REPORT CONTENT AND SAVE TO GIT =====*/
%let BASE_URI=%sysfunc(getoption(SERVICESBASEURL));
FILENAME rptFile TEMP encoding = 'UTF8';
PROC HTTP 
	METHOD="GET" 
	oauth_bearer=sas_services 
	OUT=rptFile
    URL = "&BASE_URI/reports/reports/6d637247-1566-45c1-8222-dcdab470d58f/content";
    HEADERS "Accept" = "application/vnd.sas.report.content+json";

RUN;

LIBNAME rptFile json; 
%put %sysfunc( jsonpp(rptFile, log)); 

filename latf "/home/users/&sysuserid./GIT_folder/testL.json"  encoding='UTF8';

data _null_;
    infile rptFile lrecl=32767;
    file latf lrecl=32767;
    input;
    put _infile_;
run;



/* ====== EXTRACT REPORT ETAG ==== */
Filename outhead temp ;
PROC HTTP 

URL = "&BASE_URI/reports/reports/6d637247-1566-45c1-8222-dcdab470d58f"
METHOD="GET" 
oauth_bearer=sas_services 
OUT=rptFile
headerout = outhead
headerout_overwrite ;          
run;


data _null_;
    infile outhead;
    input;
    if index(_infile_, 'ETag:') then do;
        call symputx('etag', scan(_infile_, 2, '"'));
    end;
run;

%put WARNING: &etag.;
data _null_;
infile outhead;
input ;
put _infile_;
run;


/* ==== UPDATE REPORT WITH EDITED JSON ======*/
filename resp1 temp encoding = 'UTF8';
proc http
	method = 'PUT'
	oauth_bearer=sas_services
	url = "&BASE_URI/reports/reports/6d637247-1566-45c1-8222-dcdab470d58f/content"
	in =  /*rptFile */"/home/users/&sysuserid./GIT_folder/testL2.json"  
	out = resp1; 

	headers 

		"Content-Type"="application/vnd.sas.report.content+json" 
        "Accept"="application/json"
		"If-Match" = """&etag.""";

		;
run;
LIBNAME resp1 json; 
		
filename rptFIle clear;

 

 

An error occurred. The content is invalid, possibly in the wrong format.

An error occurred. The content is invalid, possibly in the wrong format.

2 REPLIES 2
ballardw
Super User

If you are getting this error in the LOG it greatly helps to include the LOG with the code and all the messages, notes and errors.

 

Otherwise we are guessing as to where exactly in your code the error occurred. Also, often errors can be traced to prior warnings or notes.

 

 

MWallace
Calcite | Level 5

Hi, there are no errors in the log. The error is in the API response: The log is:

1    %studio_hide_wrapper;
83   /* === EXTRACT REPORT CONTENT AND SAVE TO GIT =====*/
84   %let BASE_URI=%sysfunc(getoption(SERVICESBASEURL));
85   FILENAME rptFile TEMP encoding = 'UTF8';
86   PROC HTTP
87   METHOD="GET"
88   oauth_bearer=sas_services
89   OUT=rptFile
90       URL = "&BASE_URI/reports/reports/6d637247-1566-45c1-8222-dcdab470d58f/content";
91       HEADERS "Accept" = "application/vnd.sas.report.content+json";
92   
93   RUN;
NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds
      
94   
95   LIBNAME rptFile json;
NOTE: JSON data is only read once.  To read the JSON again, reassign the JSON LIBNAME.
NOTE: Libref RPTFILE was successfully assigned as follows: 
      Engine:        JSON 
      Physical Name: /sastemp/SAS_work896B001EA2E3_micro-sasviya-ris-c.prod.aavs.ns2p.corp.hmrc.gov.uk/#LN00020
96   %put %sysfunc( jsonpp(rptFile, log));
{
  "@element": "SASReport",
  "xmlns": "http://www.sas.com/sasreportmodel/bird-4.2.4",
  "label": "Export_import_test",
  "dateCreated": "2025-08-20T12:46:06Z",
  "createdApplicationName": "SAS Visual Analytics 8.5.2",
  "dateModified": "2025-08-20T12:46:06Z",
  "lastModifiedApplicationName": "SAS Visual Analytics 8.5.2",
  "createdVersion": "4.2.4",
  "createdLocale": "en",
  "nextUniqueNameIndex": 9,
  "visualElements": [
    {
      "@element": "Text",
      "name": "ve8",
      "labelAttribute": "Text 1",
      "selectionDisabled": "true",
      "paragraphList": [
        {
          "@element": "P",
          "styleClass": "paragraph1",
          "elements": [
            {
              "@element": "Span",
              "elements": [
                {
                  "@element": "Span",
                  "elements": [
                    {
                      "@element": "TextString",
                      "text": "THIS IS THE INITIAL VERSION"
                    }
                  ],
                  "styleClass": "span2"
                }
              ],
              "styleClass": "span1"
            }
          ]
        }
      ],
      "applyDynamicBrushes": "no"
    }
  ],
  "view": {
    "@element": "View",
    "sections": [
      {
        "@element": "Section",
        "name": "vi6",
        "label": "Page 1",
        "body": {
          "@element": "Body",
          "mediaContainerList": [
            {
              "@element": "MediaContainer",
              "target": "mt2",
              "layout": {
                "@element": "ResponsiveLayout",
                "orientation": "vertical",
                "overflow": "fit",
                "weights": [
                  {
                    "@element": "Weights",
                    "mediaTarget": "mt5",
                    "unit": "percent",
                    "values": [
                      {
                        "@element": "Weight",
                        "value": "100%"
                      }
                    ]
                  },
                  {
                    "@element": "Weights",
                    "mediaTarget": "mt4",
                    "unit": "percent",
                    "values": [
                      {
                        "@element": "Weight",
                        "value": "100%"
                      }
                    ]
                  },
                  {
                    "@element": "Weights",
                    "mediaTarget": "mt3",
                    "unit": "percent",
                    "values": [
                      {
                        "@element": "Weight",
                        "value": "100%"
                      }
                    ]
                  }
                ]
              },
              "containedElementList": [
                {
                  "@element": "Visual",
                  "name": "vi7",
                  "ref": "ve8",
                  "responsiveConstraint": {
                    "@element": "ResponsiveConstraint",
                    "widthConstraint": {
                      "@element": "Responsive_WidthConstraint",
                      "widths": [
                        {
                          "@element": "Width",
                          "mediaTarget": "mt3",
                          "preferredSizeBehavior": "ignore",
                          "flexibility": "flexible"
                        }
                      ]
                    },
                    "heightConstraint": {
                      "@element": "Responsive_HeightConstraint",
                      "heights": [
                        {
                          "@element": "Height",
                          "mediaTarget": "mt3",
                          "preferredSizeBehavior": "honor",
                          "flexibility": "fixed"
                        }
                      ]
                    }
                  }
                }
              ]
            }
          ]
        }
      }
    ]
  },
  "mediaSchemes": [
    {
      "@element": "MediaScheme",
      "name": "ms1",
      "baseStylesheetResource": {
        "@element": "BaseStylesheetResource",
        "theme": "opal"
      },
      "stylesheet": {
        "@element": "Stylesheet",
        "cdata": "\n\n#ve8 .paragraph1 {\n  text-align: center;\n}\n#ve8 .span2 {\n  font-weight: bold;\n}\n#ve8 .span1 {\n  
font-size: 20pt;\n}\n\n\t\t\t",
        "styles": {
          "#ve8 .paragraph1": {
            "@element": "Style",
            "styleName": "#ve8 .paragraph1",
            "properties": {
              "text-align": "center"
            }
          },
          "#ve8 .span2": {
            "@element": "Style",
            "styleName": "#ve8 .span2",
            "properties": {
              "font-weight": "bold"
            }
          },
          "#ve8 .span1": {
            "@element": "Style",
            "styleName": "#ve8 .span1",
            "properties": {
              "font-size": "20pt"
            }
          }
        }
      }
    }
  ],
  "mediaTargets": [
    {
      "@element": "MediaTarget",
      "name": "mt2",
      "windowSize": "default",
      "scheme": "ms1"
    },
    {
      "@element": "MediaTarget",
      "name": "mt3",
      "windowSize": "small",
      "scheme": "ms1"
    },
    {
      "@element": "MediaTarget",
      "name": "mt4",
      "windowSize": "medium",
      "scheme": "ms1"
    },
    {
      "@element": "MediaTarget",
      "name": "mt5",
      "windowSize": "large",
      "scheme": "ms1"
    }
  ],
  "exportProperties": [
    {
      "@element": "Export",
      "destination": "pdf",
      "exportPropertyList": [
        {
          "@element": "Export_Property",
          "key": "showCoverPage",
          "value": "true",
          "content": ""
        },
        {
          "@element": "Export_Property",
          "key": "showPageNumbers",
          "value": "true",
          "content": ""
        }
      ]
    }
  ],
  "history": {
    "@element": "History",
    "versions": [
      {
        "@element": "Version",
        "versionKey": "4.2.4",
        "lastDate": "2025-09-12T15:23:03Z"
      }
    ],
    "editors": [
      {
        "@element": "Editor",
        "applicationName": "VA",
        "revisions": [
          {
            "@element": "Revision",
            "editorVersion": "8.5.2",
            "lastDate": "2025-08-20T12:46:06.050Z"
          }
        ]
      }
    ]
  },
  "sasReportState": {
    "@element": "SASReportState",
    "view": {
      "@element": "View_State"
    }
  }
}
0
97   
98   filename latf "/home/users/&sysuserid./GIT_folder/testL.json"  encoding='UTF8';
99   
100  data _null_;
101      infile rptFile lrecl=32767;
102      file latf lrecl=32767;
103      input;
104      put _infile_;
105  run;
NOTE: The infile RPTFILE is:
      Filename=/sastemp/SAS_work896B001EA2E3_micro-sasviya-ris-c.prod.aavs.ns2p.corp.hmrc.gov.uk/#LN00020,
      Owner Name=7259891,Group Name=Domain Users,
      Access Permission=-rw-rw-r--,
      Last Modified=12 September 2025 16:23:03,
      File Size (bytes)=3391
NOTE: The file LATF is:
      Filename=/home/users/7259891/GIT_folder/testL.json,
      Owner Name=7259891,Group Name=Domain Users,
      Access Permission=-rw-rw-r--,
      Last Modified=12 September 2025 16:23:03
NOTE: 1 record was read from the infile RPTFILE.
      The minimum record length was 3388.
      The maximum record length was 3388.
NOTE: 1 record was written to the file LATF.
      The minimum record length was 3388.
      The maximum record length was 3388.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
106  
107  
108  
109  /* ====== EXTRACT REPORT ETAG ==== */
110  Filename outhead temp ;
111  PROC HTTP
112  
113  URL = "&BASE_URI/reports/reports/6d637247-1566-45c1-8222-dcdab470d58f"
114  METHOD="GET"
115  oauth_bearer=sas_services
116  OUT=rptFile
117  headerout = outhead
118  headerout_overwrite ;
119  run;
NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      
120  
121  
122  data _null_;
123      infile outhead;
124      input;
125      if index(_infile_, 'ETag:') then do;
126          call symputx('etag', scan(_infile_, 2, '"'));
127      end;
128  run;
NOTE: The infile OUTHEAD is:
      Filename=/sastemp/SAS_work896B001EA2E3_micro-sasviya-ris-c.prod.aavs.ns2p.corp.hmrc.gov.uk/#LN00024,
      Owner Name=7259891,Group Name=Domain Users,
      Access Permission=-rw-rw-r--,
      Last Modified=12 September 2025 16:23:03,
      File Size (bytes)=701
NOTE: 19 records were read from the infile OUTHEAD.
      The minimum record length was 0.
      The maximum record length was 107.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
129  
130  %put WARNING: &etag.;
WARNING: mfgz0hgn
131  data _null_;
132  infile outhead;
133  input ;
134  put _infile_;
135  run;
NOTE: The infile OUTHEAD is:
      Filename=/sastemp/SAS_work896B001EA2E3_micro-sasviya-ris-c.prod.aavs.ns2p.corp.hmrc.gov.uk/#LN00024,
      Owner Name=7259891,Group Name=Domain Users,
      Access Permission=-rw-rw-r--,
      Last Modified=12 September 2025 16:23:03,
      File Size (bytes)=701
HTTP/1.1 200 
Date: Fri, 12 Sep 2025 15:23:03 GMT
Server: Apache/2.4
Vary: Origin,User-Agent,Access-Control-Request-Method,Access-Control-Request-Headers
SAS-Service-Response-Flag: true
Last-Modified: Fri, 12 Sep 2025 15:06:53 GMT
ETag: "mfgz0hgn"
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Content-Security-Policy: default-src 'self'; object-src 'none'; frame-ancestors 'self'; form-action 'self';
Content-Type: application/json; charset=utf-8
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
NOTE: 19 records were read from the infile OUTHEAD.
      The minimum record length was 0.
      The maximum record length was 107.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
136  
137  
138  /* ==== UPDATE REPORT WITH EDITED JSON ======*/
139  filename resp1 temp encoding = 'UTF8';
140  proc http
141  method = 'PUT'
142  oauth_bearer=sas_services
143  url = "&BASE_URI/reports/reports/6d637247-1566-45c1-8222-dcdab470d58f/content"
144  in =  /*rptFile */"/home/users/&sysuserid./GIT_folder/testL2.json"
145  out = resp1;
146  
147  headers
148  
149  "Content-Type"="application/vnd.sas.report.content+json"
150          "Accept"="application/json"
151  "If-Match" = """&etag.""";
152  
153  ;
154  run;
NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
155  LIBNAME resp1 json;
NOTE: JSON data is only read once.  To read the JSON again, reassign the JSON LIBNAME.
NOTE: Libref RESP1 was successfully assigned as follows: 
      Engine:        JSON 
      Physical Name: /sastemp/SAS_work896B001EA2E3_micro-sasviya-ris-c.prod.aavs.ns2p.corp.hmrc.gov.uk/#LN00025
156  
157  filename rptFIle clear;
NOTE: Fileref RPTFILE has been deassigned.
158  
159  %studio_hide_wrapper;
170  
171  

The API response is :

1
errorCode
 
1
10755
1
message
 
1
An error occurred. The content is invalid, possibly in the wrong format.
1
details
 
0
 
2
details
details1
1
traceId: 3ea109edaee4b9ef
2
details
details2
1
path: /reports/reports/6d637247-1566-45c1-8222-dcdab470d58f/content
1
links
 
0
 
1
version
 
1
2
1
httpStatusCode
 
1
400

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 359 views
  • 0 likes
  • 2 in conversation