Azure Blockchain Workbench specific API not working

Ramanjani, Rajiv 26 Reputation points
2020-06-18T20:12:12.77+00:00

The api/v2/contracts is NOT working. However the api/v2/contracts/{contractId} is working. We need the api/v2/contracts to be working.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,655 questions
{count} votes

Accepted answer
  1. SanaCMSFT-8922 301 Reputation points
    2020-06-24T08:35:30.783+00:00

    If you expand the particular operation, in this case, GET /api/v1/contracts, you should be able to see the parameters that you would have to provide for the particular request. If the parameters are not provided, their default values are used. In this case, since workflow Id was not provided, the default value "0" was used along with the respective default values for the other parameters which ended up giving an error since there is no workflow id of 0 for the deployment.

    Let us know if you need any further clarification.

    Thanks,
    Sana


3 additional answers

Sort by: Most helpful
  1. Ramanjani, Rajiv 26 Reputation points
    2020-06-23T08:54:33.287+00:00

    Hi Sana,
    Here is the 'Exact' issue:

    a. I try to do a GET request with this API endpoint URL : https://p8blkchwkbench-bk3m3c-api.azurewebsites.net/api/v2/contracts

    I get a 404 - Resource Not found error

    b. I try to do a GET request with this API endpoint URL : https://p8blkchwkbench-bk3m3c-api.azurewebsites.net/api/v2/contracts/344

    I get a 200 with proper response from JSON.

    c. Documentation for the API calls is here: https://p8blkchwkbench-bk3m3c-api.azurewebsites.net/

    d. The console logs of my web app service for both the successful one and the unsuccessful one are given below:

    2020-06-23T08:52:40.494160092Z [08:52:40 INF] {Protocol="HTTP/1.1", Method="GET", ContentType=null, ContentLength=null, Scheme="http", Host="p8blkchwkbench-bk3m3c-api.azurewebsites.net", PathBase="", Path="/api/v2/contracts/344", QueryString="", EventId={Id=1}, SourceContext="Microsoft.AspNetCore.Hosting.Internal.WebHost", RequestId="0HM0HSS2FG6SF:00000001", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Request starting HTTP/1.1 GET http://p8blkchwkbench-bk3m3c-api.azurewebsites.net/api/v2/contracts/344
    2020-06-23T08:52:40.496391406Z [08:52:40 INF] {EventId={Id=2}, SourceContext="Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler", RequestId="0HM0HSS2FG6SF:00000001", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Successfully validated the token.
    2020-06-23T08:52:40.499864329Z [08:52:40 INF] {EventId={Id=8}, SourceContext="Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler", RequestId="0HM0HSS2FG6SF:00000001", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} AuthenticationScheme: Bearer was successfully authenticated.
    2020-06-23T08:52:40.500649533Z [08:52:40 INF] {SourceContext="data-access", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Execute [dbo].[GetUserByExternalId] with externalId = 3d5a609c-0de8-4cb7-a64f-b28580c9977d
    2020-06-23T08:52:40.501213937Z [08:52:40 INF] {SourceContext="data-access", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Executing sproc [dbo].[GetUserByExternalId]
    2020-06-23T08:52:40.512952711Z [08:52:40 INF] {SourceContext="data-access", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Execute [dbo].[GetUserChainMappings] with id = 4
    2020-06-23T08:52:40.513741616Z [08:52:40 INF] {SourceContext="data-access", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Executing sproc [dbo].[GetUserChainMappings]
    2020-06-23T08:52:40.519059650Z [08:52:40 INF] {EventId={Id=1}, SourceContext="Microsoft.AspNetCore.Authorization.DefaultAuthorizationService", ActionId="b16abfb7-4fe8-43a6-95ab-a1a313df5b2a", ActionName="Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractGet (Microsoft.AppBuilder.API)", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Authorization was successful for user: XXXXXXXXXXXXXXXX.
    2020-06-23T08:52:40.520115957Z [08:52:40 INF] {EventId={Id=1}, SourceContext="Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker", ActionId="b16abfb7-4fe8-43a6-95ab-a1a313df5b2a", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Executing action method Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractGet (Microsoft.AppBuilder.API) with arguments (["344"]) - ModelState is Valid
    2020-06-23T08:52:40.520736161Z [08:52:40 INF] {SourceContext="data-access", ActionId="b16abfb7-4fe8-43a6-95ab-a1a313df5b2a", ActionName="Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractGet (Microsoft.AppBuilder.API)", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Execute [dbo].[GetContract] with contractId = 344, userId = 4, isAdmin = True
    2020-06-23T08:52:40.521628566Z [08:52:40 INF] {SourceContext="data-access", ActionId="b16abfb7-4fe8-43a6-95ab-a1a313df5b2a", ActionName="Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractGet (Microsoft.AppBuilder.API)", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Executing sproc [dbo].[GetContract]
    2020-06-23T08:52:40.536901463Z [08:52:40 INF] {EventId={Id=1}, SourceContext="Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutor", ActionId="b16abfb7-4fe8-43a6-95ab-a1a313df5b2a", ActionName="Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractGet (Microsoft.AppBuilder.API)", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext.
    2020-06-23T08:52:40.539096077Z [08:52:40 INF] {EventId={Id=2}, SourceContext="Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker", ActionId="b16abfb7-4fe8-43a6-95ab-a1a313df5b2a", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Executed action Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractGet (Microsoft.AppBuilder.API) in 20.1865ms
    2020-06-23T08:52:40.541259891Z [08:52:40 INF] {ElapsedMilliseconds=47.6312, StatusCode=200, ContentType="application/json; charset=utf-8", EventId={Id=2}, SourceContext="Microsoft.AspNetCore.Hosting.Internal.WebHost", RequestId="c938a005-4678-4d53-a384-7bb998d07b36", RequestPath="/api/v2/contracts/344", ServiceName="appbuilder.api"} Request finished in 47.6312ms 200 application/json; charset=utf-8
    

    2020-06-23T08:52:52.299079157Z [08:52:52 INF] {Protocol="HTTP/1.1", Method="GET", ContentType=null, ContentLength=null, Scheme="http", Host="p8blkchwkbench-bk3m3c-api.azurewebsites.net", PathBase="", Path="/api/v2/contracts", QueryString="", EventId={Id=1}, SourceContext="Microsoft.AspNetCore.Hosting.Internal.WebHost", RequestId="0HM0HSS2FG6SG:00000001", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Request starting HTTP/1.1 GET http://p8blkchwkbench-bk3m3c-api.azurewebsites.net/api/v2/contracts
    2020-06-23T08:52:52.301575073Z [08:52:52 INF] {EventId={Id=2}, SourceContext="Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler", RequestId="0HM0HSS2FG6SG:00000001", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Successfully validated the token.
    2020-06-23T08:52:52.301833875Z [08:52:52 INF] {EventId={Id=8}, SourceContext="Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler", RequestId="0HM0HSS2FG6SG:00000001", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} AuthenticationScheme: Bearer was successfully authenticated.
    2020-06-23T08:52:52.302101876Z [08:52:52 INF] {SourceContext="data-access", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Execute [dbo].[GetUserByExternalId] with externalId = 3d5a609c-0de8-4cb7-a64f-b28580c9977d
    2020-06-23T08:52:52.303731187Z [08:52:52 INF] {SourceContext="data-access", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Executing sproc [dbo].[GetUserByExternalId]
    2020-06-23T08:52:52.308975720Z [08:52:52 INF] {SourceContext="data-access", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Execute [dbo].[GetUserChainMappings] with id = 4
    2020-06-23T08:52:52.309884526Z [08:52:52 INF] {SourceContext="data-access", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Executing sproc [dbo].[GetUserChainMappings]
    2020-06-23T08:52:52.314373354Z [08:52:52 INF] {EventId={Id=1}, SourceContext="Microsoft.AspNetCore.Authorization.DefaultAuthorizationService", ActionId="7e74b811-c8b1-41b5-a666-7538ff0e7a7c", ActionName="Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractsGet (Microsoft.AppBuilder.API)", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Authorization was successful for user: XXXXXXXXXXXXXXXXXX.
    2020-06-23T08:52:52.315218860Z [08:52:52 INF] {EventId={Id=1}, SourceContext="Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker", ActionId="7e74b811-c8b1-41b5-a666-7538ff0e7a7c", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Executing action method Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractsGet (Microsoft.AppBuilder.API) with arguments (["", "", "0", ""]) - ModelState is Valid
    2020-06-23T08:52:52.316045665Z [08:52:52 INF] {SourceContext="data-access", ActionId="7e74b811-c8b1-41b5-a666-7538ff0e7a7c", ActionName="Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractsGet (Microsoft.AppBuilder.API)", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Execute [dbo].[GetContracts] with top = null, skip = null, workflowId = 0, userId = 4, isAdmin = True, sortBy = null
    2020-06-23T08:52:52.316689469Z [08:52:52 INF] {SourceContext="data-access", ActionId="7e74b811-c8b1-41b5-a666-7538ff0e7a7c", ActionName="Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractsGet (Microsoft.AppBuilder.API)", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Executing sproc [dbo].[GetContracts]
    2020-06-23T08:52:52.323091310Z [08:52:52 INF] {SourceContext="data-access", ActionId="7e74b811-c8b1-41b5-a666-7538ff0e7a7c", ActionName="Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractsGet (Microsoft.AppBuilder.API)", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Encountered entity not found in operation [dbo].[GetContracts], Workflow Id 0 not found.
    2020-06-23T08:52:52.324734620Z [08:52:52 INF] {EventId={Id=2}, SourceContext="Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker", ActionId="7e74b811-c8b1-41b5-a666-7538ff0e7a7c", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Executed action Microsoft.AppBuilder.API.Controllers.ContractsV2Controller.ContractsGet (Microsoft.AppBuilder.API) in 10.4769ms
    2020-06-23T08:52:52.326394831Z [08:52:52 INF] {ElapsedMilliseconds=27.4234, StatusCode=404, ContentType="application/json", EventId={Id=2}, SourceContext="Microsoft.AspNetCore.Hosting.Internal.WebHost", RequestId="b4181e50-f16e-4623-a484-e45146275e95", RequestPath="/api/v2/contracts", ServiceName="appbuilder.api"} Request finished in 27.4234ms 404 application/json
    
    0 comments No comments

  2. MSFT Azure Blockchain Team 1 Reputation point
    2020-06-24T07:16:13.323+00:00

    Hi @RamanjaniRajiv-1749,

    Thank you for sharing the logs.

    Looking at the logs and the URL used, it seems like the workflow ID parameter has not been provided. Please use this API endpoint URL to make the GET request: https://p8blkchwkbench-bk3m3c-api.azurewebsites.net/api/v2/contracts?workflowId=\<workflowID> (Replace <workflowID> here with the appropriate workflow ID).

    Let us know if this works for you or if you need any further help.

    Thanks,
    Sana

    0 comments No comments

  3. Ramanjani, Rajiv 26 Reputation points
    2020-06-24T08:20:17.053+00:00

    The workflow id made it work. But the swagger documentation for it here: https://p8blkchwkbench-bk3m3c-api.azurewebsites.net/

    does not seem to indicate the necessity for the wofkflowid as a parameter at all. Please find attached the screenshot. Is there something wrong with the default generated swagger documentation?
    10621-contracts.jpg

    0 comments No comments