cancel
Showing results for 
Search instead for 
Did you mean: 

405 Method Not Allowed when trying HTTP method POST in SAP Gateway Client

YS1990
Explorer
694

Hi,

I'm trying to make a sample of POST data in SEGW that call a BAPI. I follow this tutorial step by step:

Step-by-step Creation of sales order using BAPI in... - SAP Community

However, when I try to POST through SAP Gateway Client, there is error 405 Method Not Allowed. I already tried some solutions including tick Creatable, Updatable in Entity Properties but the error 405 persists.
I also try to create another SEGW project that call a simple BAPI to insert data to my ZTable, but
The similar error 405 also happens

HTTP Status Code : 405
Error Text : The specified HTTP method is not allowed for the resource identified by the Data Service Request URI
T100 Error ID : /IWFND/CM_CONSUMER122

I also make other SEGW sample project to GET data from a BAPI as well, it works well and everything is okay. The problem only happens when I POST data to a BAPI create.
Is there any solution for this error? Is is related to networking setting/configuration?

 
 
junwu
Active Contributor
0 Kudos
show us your post call payload
junwu
Active Contributor
0 Kudos
and url for the post call
YS1990
Explorer
0 Kudos
Thanks I have posted the screnshot and the HTTP request body
YS1990
Explorer
0 Kudos
The Data Services Request contains SystemQueryOptions that are not allowed for this Request Type

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

remove $format=json

junwu
Active Contributor
0 Kudos
@YS1990 did you try this?
YS1990
Explorer
0 Kudos
I have tried... still error. The only way to make POST succeed is through $Batch. I still don't know why and if it is applicable when ultimately used by other app. I have posted the screnshot in another answer. May be you know why the post only works when I use $Batch ?
junwu
Active Contributor
0 Kudos
@YS1990 show me your screenshot for this case.
YS1990
Explorer
0 Kudos
I already posted the screnshot on a new answer
junwu
Active Contributor
0 Kudos

@YS1990  are you sure you have tried like this?

/sap/opu/odata/sap/Z_ODTSLSORDCRT_SRV/SalesOrderSet

request body 

{ "DocType" : "TA", "SalesOrg" : "8900", "DistrChan" : "10", "Division" : "11", "TextLine" : "coba text", "ItmNumber" : "000010", "ReqQty" : "15.000", "PartnRole" : "AG", "PartnNumb" : "0001000000", "Material" : "000000000030000032", "Plant" : "8921", "TargetQty" : "15.000", "CondType" : "", "CondValue" : "0.000000000" }

junwu
Active Contributor
0 Kudos
I don't see any screenshot like that.
YS1990
Explorer
0 Kudos
Thanks junwu it works. Sorry I have not removed $format=json in my previous trial. I just focus on using $Batch that works

Answers (5)

Answers (5)

YS1990
Explorer
0 Kudos

Hi, 
I just find that when I use $Batch, write the POST method in it, then the POST succeed
I don't know why, when I don't use $Batch, the POST  always error 405

YS1990
Explorer
0 Kudos

Hi Junwu,

I tried to change my request body and still error (404)
with this url
/sap/opu/odata/sap/Z_ODTSLSORDCRT_SRV/SalesOrderSet?$format=json
and

Error (405) with this url
/sap/opu/odata/sap/Z_ODTSLSORDCRT_SRV/SalesOrderSet('0050000004')?$format=json

Both the request body is
{
    "DocType" "TA",
    "SalesOrg" "8900",
    "DistrChan" "10",
    "Division" "11",
    "TextLine" "coba text",
    "ItmNumber" "000010",
    "ReqQty" "15.000",
    "PartnRole" "AG",
    "PartnNumb" "0001000000",
    "Material" "000000000030000032",
    "Plant" "8921",
    "TargetQty" "15.000",
    "CondType" "",
    "CondValue" "0.000000000"
}

 

 

 

junwu
Active Contributor
0 Kudos

you are not following correctly.

{
 
    "DocType" "TA",
    "SalesOrg" "8900",
    "DistrChan" "10",
    "Division" "11",
    "TextLine" "coba text",
    "ItmNumber" "000010",
    "ReqQty" "15.000",
    "PartnRole" "AG",
    "PartnNumb" "0001000000",
    "Material" "000000000030000032",
    "Plant" "8921",
    "TargetQty" "15.000",
    "CondType" "",
    "CondValue" "0.000000000"
 
}

YS1990
Explorer
0 Kudos
Junwu, thanks, but I tried it and still error... I have posted the screnshot on other answer because I can not attach picture in this comment section
junwu
Active Contributor
0 Kudos

if you want to test "create", you have to remove ("***") from the url, entityset name is enough

junwu
Active Contributor
0 Kudos
if you want to test "update", change the method to patch/merge.
YS1990
Explorer
0 Kudos
I changed url to : /sap/opu/odata/sap/Z_ODTSLSORDCRT_SRV/SalesOrderSet?$format=json
YS1990
Explorer
0 Kudos
I changed url to : /sap/opu/odata/sap/Z_ODTSLSORDCRT_SRV/SalesOrderSet?$format=json. And then I POST it with similar data in the previous screnshot. The result is Error Status Code 400 Bad Request
junwu
Active Contributor
0 Kudos

remove this part in your payload for post call

"d" : {
    "__metadata" : {
      "id" "http://hostname.local:8004/sap/opu/odata/sap/Z_ODTSLSORDCRT_SRV/SalesOrderSet('50000004')",
      "uri" "http://hostname.local:8004/sap/opu/odata/sap/Z_ODTSLSORDCRT_SRV/SalesOrderSet('50000004')",
      "type" "Z_ODTSLSORDCRT_SRV.SalesOrder"
    },

YS1990
Explorer
0 Kudos
{ "d" : { "Salesdocumentin" : "50000004", "DocType" : "TA", "SalesOrg" : "8900", "DistrChan" : "10", "Division" : "11", "TextLine" : "coba text", "ItmNumber" : "000010", "ReqQty" : "15.000", "PartnRole" : "AG", "PartnNumb" : "0001000000", "Material" : "000000000030000032", "Plant" : "8921", "TargetQty" : "15.000", "CondType" : "", "CondValue" : "0.000000000" } } and { "Salesdocumentin" : "50000004", "DocType" : "TA", "SalesOrg" : "8900", "DistrChan" : "10", "Division" : "11", "TextLine" : "coba text", "ItmNumber" : "000010", "ReqQty" : "15.000", "PartnRole" : "AG", "PartnNumb" : "0001000000", "Material" : "000000000030000032", "Plant" : "8921", "TargetQty" : "15.000", "CondType" : "", "CondValue" : "0.000000000" } similar Error both 405 Method Not Allowed
YS1990
Explorer
0 Kudos

Screenshot 2024-09-19 081041.pngScreenshot 2024-09-19 081220.png
{
  "d" : {
    "__metadata" : {
      "id" "http://hostname.local:8004/sap/opu/odata/sap/Z_ODTSLSORDCRT_SRV/SalesOrderSet('50000004')",
      "uri" "http://hostname.local:8004/sap/opu/odata/sap/Z_ODTSLSORDCRT_SRV/SalesOrderSet('50000004')",
      "type" "Z_ODTSLSORDCRT_SRV.SalesOrder"
    },
    "DocType" "TA",
    "SalesOrg" "8900",
    "DistrChan" "10",
    "Division" "11",
    "TextLine" "coba text",
    "ItmNumber" "000010",
    "ReqQty" "15.000",
    "PartnRole" "AG",
    "PartnNumb" "0001000000",
    "Material" "000000000030000032",
    "Plant" "8921",
    "TargetQty" "15.000",
    "CondType" "",
    "CondValue" "0.000000000"
  }
}

kyo_choi2
Participant
0 Kudos
Can you debug at the implement code?
YS1990
Explorer
0 Kudos
Nah, I try to put a breakpoint but when I call the POST, it didn't debug. When I use /h, it only debug PAI method on Gateway UI